Skip to content

Commit ae4ec8d

Browse files
committed
fix for #209
1 parent 949df4f commit ae4ec8d

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

caldav/davclient.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def __init__(
101101
self, response: Response, davclient: Optional["DAVClient"] = None
102102
) -> None:
103103
self.headers = response.headers
104+
self.status = response.status_code
104105
log.debug("response headers: " + str(self.headers))
105106
log.debug("response status: " + str(self.status))
106107

@@ -114,7 +115,7 @@ def __init__(
114115
no_xml = ["text/plain", "text/calendar", "application/octet-stream"]
115116
expect_xml = any((content_type.startswith(x) for x in xml))
116117
expect_no_xml = any((content_type.startswith(x) for x in no_xml))
117-
if content_type and not expect_xml and not expect_no_xml:
118+
if content_type and not expect_xml and not expect_no_xml and response.status_code<400:
118119
error.weirdness(f"Unexpected content type: {content_type}")
119120
try:
120121
content_length = int(self.headers["Content-Length"])
@@ -350,11 +351,13 @@ def _expand_simple_prop(
350351
values = []
351352
if proptag in props_found:
352353
prop_xml = props_found[proptag]
353-
if prop_xml.items():
354-
from caldav.lib.debug import xmlstring
355-
354+
for item in prop_xml.items():
355+
if item[0].lower().endswith('content-type') and item[1].lower() == 'text/calendar':
356+
continue
357+
if item[0].lower().endswith('version') and item[1] in ("2", "2.0"):
358+
continue
356359
log.error(
357-
f"If you see this, please add a report at https://github.com/python-caldav/caldav/issues/209 - in _expand_simple_prop, dealing with {proptag}, extra items found: {xmlstring(prop_xml)}."
360+
f"If you see this, please add a report at https://github.com/python-caldav/caldav/issues/209 - in _expand_simple_prop, dealing with {proptag}, extra item found: {'='.join(item)}."
358361
)
359362
if not xpath and len(prop_xml) == 0:
360363
if prop_xml.text:

0 commit comments

Comments
 (0)