From d6d2c006ad0a0aee9602fd9205bf31cebd4597db Mon Sep 17 00:00:00 2001 From: Unrud Date: Sun, 17 Sep 2017 14:03:54 +0200 Subject: [PATCH] Add DAV:getcontentlength property to leaf collections --- radicale/xmlutils.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/radicale/xmlutils.py b/radicale/xmlutils.py index 5639f4c..8b6218d 100644 --- a/radicale/xmlutils.py +++ b/radicale/xmlutils.py @@ -962,6 +962,12 @@ def _propfind_response(base_prefix, path, item, props, user, write=False, report_tag.append(supported_report_tag) supported.append(report_tag) element.append(supported) + elif tag == _tag("D", "getcontentlength"): + if not is_collection or is_leaf: + encoding = collection.configuration.get("encoding", "request") + element.text = str(len(item.serialize().encode(encoding))) + else: + is404 = True elif is_collection: if tag == _tag("D", "getcontenttype"): if is_leaf: @@ -1022,9 +1028,6 @@ def _propfind_response(base_prefix, path, item, props, user, write=False, elif tag == _tag("D", "resourcetype"): # resourcetype must be returned empty for non-collection elements pass - elif tag == _tag("D", "getcontentlength"): - encoding = collection.configuration.get("encoding", "request") - element.text = str(len(item.serialize().encode(encoding))) else: is404 = True