Don't return empty PROPSTAT elements in PROPFIND responses
This should not have any impact on clients.
This commit is contained in:
parent
e11661ff3e
commit
262d76cc87
@ -17,6 +17,7 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Radicale. If not, see <http://www.gnu.org/licenses/>.
|
# along with Radicale. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import collections
|
||||||
import itertools
|
import itertools
|
||||||
import posixpath
|
import posixpath
|
||||||
import socket
|
import socket
|
||||||
@ -63,11 +64,9 @@ def xml_propfind(base_prefix, path, xml_request, allowed_items, user,
|
|||||||
|
|
||||||
for item, permission in allowed_items:
|
for item, permission in allowed_items:
|
||||||
write = permission == "w"
|
write = permission == "w"
|
||||||
response = xml_propfind_response(
|
multistatus.append(xml_propfind_response(
|
||||||
base_prefix, path, item, props, user, encoding, write=write,
|
base_prefix, path, item, props, user, encoding, write=write,
|
||||||
allprop=allprop, propname=propname)
|
allprop=allprop, propname=propname))
|
||||||
if response:
|
|
||||||
multistatus.append(response)
|
|
||||||
|
|
||||||
return client.MULTI_STATUS, multistatus
|
return client.MULTI_STATUS, multistatus
|
||||||
|
|
||||||
@ -93,20 +92,9 @@ def xml_propfind_response(base_prefix, path, item, props, user, encoding,
|
|||||||
else:
|
else:
|
||||||
uri = pathutils.unstrip_path(
|
uri = pathutils.unstrip_path(
|
||||||
posixpath.join(collection.path, item.href))
|
posixpath.join(collection.path, item.href))
|
||||||
|
|
||||||
href.text = xmlutils.make_href(base_prefix, uri)
|
href.text = xmlutils.make_href(base_prefix, uri)
|
||||||
response.append(href)
|
response.append(href)
|
||||||
|
|
||||||
propstat404 = ET.Element(xmlutils.make_tag("D", "propstat"))
|
|
||||||
propstat200 = ET.Element(xmlutils.make_tag("D", "propstat"))
|
|
||||||
response.append(propstat200)
|
|
||||||
|
|
||||||
prop200 = ET.Element(xmlutils.make_tag("D", "prop"))
|
|
||||||
propstat200.append(prop200)
|
|
||||||
|
|
||||||
prop404 = ET.Element(xmlutils.make_tag("D", "prop"))
|
|
||||||
propstat404.append(prop404)
|
|
||||||
|
|
||||||
if propname or allprop:
|
if propname or allprop:
|
||||||
props = []
|
props = []
|
||||||
# Should list all properties that can be retrieved by the code below
|
# Should list all properties that can be retrieved by the code below
|
||||||
@ -146,11 +134,11 @@ def xml_propfind_response(base_prefix, path, item, props, user, encoding,
|
|||||||
if clark_tag not in props:
|
if clark_tag not in props:
|
||||||
props.append(clark_tag)
|
props.append(clark_tag)
|
||||||
|
|
||||||
|
responses = collections.defaultdict(list)
|
||||||
if propname:
|
if propname:
|
||||||
for tag in props:
|
for tag in props:
|
||||||
prop200.append(ET.Element(tag))
|
responses[200].append(ET.Element(tag))
|
||||||
props = ()
|
props = ()
|
||||||
|
|
||||||
for tag in props:
|
for tag in props:
|
||||||
element = ET.Element(tag)
|
element = ET.Element(tag)
|
||||||
is404 = False
|
is404 = False
|
||||||
@ -306,20 +294,19 @@ def xml_propfind_response(base_prefix, path, item, props, user, encoding,
|
|||||||
else:
|
else:
|
||||||
is404 = True
|
is404 = True
|
||||||
|
|
||||||
if is404:
|
responses[404 if is404 else 200].append(element)
|
||||||
prop404.append(element)
|
|
||||||
else:
|
|
||||||
prop200.append(element)
|
|
||||||
|
|
||||||
status200 = ET.Element(xmlutils.make_tag("D", "status"))
|
for status_code, childs in responses.items():
|
||||||
status200.text = xmlutils.make_response(200)
|
if not childs:
|
||||||
propstat200.append(status200)
|
continue
|
||||||
|
propstat = ET.Element(xmlutils.make_tag("D", "propstat"))
|
||||||
status404 = ET.Element(xmlutils.make_tag("D", "status"))
|
response.append(propstat)
|
||||||
status404.text = xmlutils.make_response(404)
|
prop = ET.Element(xmlutils.make_tag("D", "prop"))
|
||||||
propstat404.append(status404)
|
prop.extend(childs)
|
||||||
if len(prop404) > 0:
|
propstat.append(prop)
|
||||||
response.append(propstat404)
|
status = ET.Element(xmlutils.make_tag("D", "status"))
|
||||||
|
status.text = xmlutils.make_response(status_code)
|
||||||
|
propstat.append(status)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user