Repository: falconry/falcon
Pull request #1588 (2019-10-23 06:25:05)

fix: WebDAV methods not supported
# Summary of Changes

Add support for all WebDAV methods (RFC 2518 and RFC 4918), such as COPY, LOCK, MKCOL, MOVE, PROPFIND, PROPPATCH and UNLOCK.

# Related Issues

#1426 

# Pull Request Checklist

This is just a reminder about the most common mistakes.  Please make sure that you tick all *appropriate* boxes.  But please read our [contribution guide](https://github.com/falconry/falcon/blob/master/CONTRIBUTING.md) at least once; it will save you a few review cycles!

If an item doesn't apply to your pull request, **check it anyway** to make it apparent that there's nothing to do.

- [x] Added **tests** for changed code.
- [x] Prefixed code comments with GitHub nick and an appropriate prefix.
- [x] Coding style is consistent with the rest of the framework.
- [x] Updated **documentation** for changed code.
    - [ ] Added docstrings for any new classes, functions, or modules.
    - [ ] Updated docstrings for any modifications to existing code.
    - [ ] Added references to new classes, functions, or modules to the relevant RST file under `docs/`.
    - [ ] Updated all relevant supporting documentation files under `docs/`.
    - [ ] A copyright notice is included at the top of any new modules (using your own name or the name of your organization).
    - [ ] Changed/added classes/methods/functions have appropriate `versionadded`, `versionchanged`, or `deprecated` [directives](http://www.sphinx-doc.org/en/stable/usage/restructuredtext/directives.html?highlight=versionadded#directive-versionadded).
- [x] Changes (and possible deprecations) have [towncrier](https://pypi.org/project/towncrier/) news fragments under `docs/_newsfragments/`. (Run `towncrier --draft` to ensure it renders correctly.)

If you have *any* questions to *any* of the points above, just **submit and ask**! This checklist is here to *help* you, not to deter you from contributing!

*PR template inspired by the attrs project.*


codecov[bot]: # [Codecov](https://codecov.io/gh/falconry/falcon/pull/1588?src=pr&el=h1) Report
> Merging [#1588](https://codecov.io/gh/falconry/falcon/pull/1588?src=pr&el=desc) into [master](https://codecov.io/gh/falconry/falcon/commit/69539387c91f80adb30d5f44e7e425afd769a6a1?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/falconry/falcon/pull/1588/graphs/tree.svg?width=650&token=zOtkfNQ3h6&height=150&src=pr)](https://codecov.io/gh/falconry/falcon/pull/1588?src=pr&el=tree)

```diff
@@          Coverage Diff           @@
##           master   #1588   +/-   ##
======================================
  Coverage     100%    100%           
======================================
  Files          38      38           
  Lines        2567    2567           
  Branches      392     392           
======================================
  Hits         2567    2567
```


| [Impacted Files](https://codecov.io/gh/falconry/falcon/pull/1588?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [falcon/constants.py](https://codecov.io/gh/falconry/falcon/pull/1588/diff?src=pr&el=tree#diff-ZmFsY29uL2NvbnN0YW50cy5weQ==) | `100% <ø> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/falconry/falcon/pull/1588?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/falconry/falcon/pull/1588?src=pr&el=footer). Last update [6953938...de372cf](https://codecov.io/gh/falconry/falcon/pull/1588?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/docs/_newsfragments/1426-webdav.feature.rst b/docs/_newsfragments/1426-webdav.feature.rst
new file mode 100644
index 0000000..41a4a76
--- /dev/null
+++ b/docs/_newsfragments/1426-webdav.feature.rst
@@ -0,0 +1,1 @@
+Falcon now supports all WebDAV methods (RFC 2518 and RFC 4918), such as COPY, LOCK, MKCOL, MOVE, PROPFIND, PROPPATCH and UNLOCK.
diff --git a/docs/changes/3.0.0.rst b/docs/changes/3.0.0.rst
new file mode 100644
index 0000000..cc0022d
--- /dev/null
+++ b/docs/changes/3.0.0.rst
@@ -0,0 +1,9 @@
+Changelog for Falcon 3.0.0
+==========================
+
+Contributors to this Release
+----------------------------
+
+Many thanks to all of our talented and stylish contributors for this release!
+
+- `screamingskulls <https://github.com/screamingskulls>`_
diff --git a/docs/changes/index.rst b/docs/changes/index.rst
index d263dde..6433277 100644
--- a/docs/changes/index.rst
+++ b/docs/changes/index.rst
@@ -3,6 +3,7 @@ Changelogs
 
 .. toctree::
 
+   3.0.0 <3.0.0>
    2.0.0 <2.0.0>
    1.4.1 <1.4.1>
    1.4.0 <1.4.0>
diff --git a/falcon/constants.py b/falcon/constants.py
index f671f4d..1c01939 100644
--- a/falcon/constants.py
+++ b/falcon/constants.py
@@ -13,12 +13,19 @@ HTTP_METHODS = [
     'TRACE',
 ]
 
-# RFC 3253 methods
+# RFC 2518 and 4918 methods
 WEBDAV_METHODS = [
     'CHECKIN',
     'CHECKOUT',
+    'COPY',
+    'LOCK',
+    'MKCOL',
+    'MOVE',
+    'PROPFIND',
+    'PROPPATCH',
     'REPORT',
     'UNCHECKIN',
+    'UNLOCK'
     'UPDATE',
     'VERSION-CONTROL',
 ]
@@ -63,7 +70,6 @@ MEDIA_YAML = 'application/yaml'
 # contrary to the RFCs.
 MEDIA_XML = 'application/xml'
 
-
 # NOTE(kgriffs): RFC 4329 recommends application/* over text/.
 # futhermore, parsers are required to respect the Unicode
 # encoding signature, if present in the document, and to default


Test patch:
diff --git a/tests/test_http_method_routing.py b/tests/test_http_method_routing.py
index 69141f3..aeae1ee 100644
--- a/tests/test_http_method_routing.py
+++ b/tests/test_http_method_routing.py
@@ -17,12 +17,18 @@ HTTP_METHODS = (
     'PATCH'
 )
 
-
 WEBDAV_METHODS = (
     'CHECKIN',
     'CHECKOUT',
+    'COPY',
+    'LOCK',
+    'MKCOL',
+    'MOVE',
+    'PROPFIND',
+    'PROPPATCH',
     'REPORT',
     'UNCHECKIN',
+    'UNLOCK'
     'UPDATE',
     'VERSION-CONTROL',
 )