[Calypso-commits] [calypso] 01/01: Return propfind-finite-depth on infinite depth requests
Guido Guenther
agx at moszumanska.debian.org
Fri Apr 15 07:22:16 UTC 2016
This is an automated email from the git hooks/post-receive script.
agx pushed a commit to branch master
in repository calypso.
commit 8930da33c93ff5fa6197968e81b87e3d01d58510
Author: Guido Günther <agx at sigxcpu.org>
Date: Fri Apr 15 09:21:37 2016 +0200
Return propfind-finite-depth on infinite depth requests
as suggested by
http://www.webdav.org/specs/rfc4918.html#rfc.section.9.1.1
This fixes large parts caldav-testers tests/CalDAV/propfind.xml and
I would be keen to find out if it breaks real world clients.
---
calypso/__init__.py | 16 +++++++++++-----
calypso/xmlutils.py | 14 ++++++++++++--
2 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/calypso/__init__.py b/calypso/__init__.py
index da02962..9819d4c 100644
--- a/calypso/__init__.py
+++ b/calypso/__init__.py
@@ -398,13 +398,19 @@ class CollectionHTTPHandler(server.BaseHTTPRequestHandler):
try:
xml_request = self.xml_request
log.debug("PROPFIND %s", xml_request)
- self._answer = xmlutils.propfind(
- self.path, xml_request, self._collection,
- self.headers.get("depth", "infinity"),
- context)
+ depth = self.headers.get("depth", "infinity")
+ if depth != "infinity":
+ self._answer = xmlutils.propfind(
+ self.path, xml_request, self._collection,
+ depth, context)
+ status = client.MULTI_STATUS
+ else:
+ self._answer = xmlutils.propfind_deny()
+ status = client.FORBIDDEN
+
log.debug("PROPFIND ANSWER %s", self._answer)
- self.send_calypso_response(client.MULTI_STATUS, len(self._answer))
+ self.send_calypso_response(status, len(self._answer))
self.send_header("DAV", "1, calendar-access")
self.send_header("Content-Type", "text/xml")
self.end_headers()
diff --git a/calypso/xmlutils.py b/calypso/xmlutils.py
index 0715764..09971e3 100644
--- a/calypso/xmlutils.py
+++ b/calypso/xmlutils.py
@@ -134,8 +134,7 @@ def propfind(path, xml_request, collection, depth, context):
if depth == "0":
items = [collection]
else:
- # depth is 1, infinity or not specified
- # we limit ourselves to depth == 1
+ # We limit ourselves to depth == 1
items = [collection] + collection.items
else:
items = []
@@ -233,6 +232,17 @@ def propfind(path, xml_request, collection, depth, context):
return ET.tostring(multistatus, config.get("encoding", "request"))
+def propfind_deny():
+ """Answer an infinity PROPFIND requests.
+
+ Read rfc4918-9.1.1 for info.
+ """
+ error = ET.Element(_tag("D", "error"))
+ prec_code = ET.Element(_tag("D", "propfind-finite-depth"))
+ error.append(prec_code)
+ return ET.tostring(error, config.get("encoding", "request"))
+
+
def put(path, webdav_request, collection, context):
"""Read PUT requests."""
name = paths.resource_from_path(path)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/calypso/calypso.git
More information about the Calypso-commits
mailing list