diff --git a/vdirsyncer/storage/dav.py b/vdirsyncer/storage/dav.py index aaea996..3936720 100644 --- a/vdirsyncer/storage/dav.py +++ b/vdirsyncer/storage/dav.py @@ -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