Fix xandikos test: multistatus parsing

This commit is contained in:
Markus Unterwaditzer 2017-05-30 11:25:52 +02:00
parent 7f80251527
commit 6a273953f7

View file

@ -41,6 +41,23 @@ def _contains_quoted_reserved_chars(x):
return False
def _assert_multistatus_success(r):
# Xandikos returns a multistatus on PUT.
try:
root = _parse_xml(r.content)
except InvalidXMLResponse:
print("INVALID RESPONSE")
return
for status in root.findall('.//{DAV:}status'):
parts = status.text.strip().split()
try:
st = int(parts[1])
except (ValueError, IndexError):
continue
if st < 200 or st >= 400:
raise HTTPError('Server error: {}'.format(st))
def _normalize_href(base, href):
'''Normalize the href to be a path only relative to hostname and
schema.'''
@ -499,6 +516,8 @@ class DAVStorage(Storage):
headers=headers
)
_assert_multistatus_success(response)
# The server may not return an etag under certain conditions:
#
# An origin server MUST NOT send a validator header field (Section