diff --git a/caldav/davclient.py b/caldav/davclient.py index fb149273..9bd3cf8c 100644 --- a/caldav/davclient.py +++ b/caldav/davclient.py @@ -101,6 +101,7 @@ def __init__( self, response: Response, davclient: Optional["DAVClient"] = None ) -> None: self.headers = response.headers + self.status = response.status_code log.debug("response headers: " + str(self.headers)) log.debug("response status: " + str(self.status)) @@ -114,7 +115,12 @@ def __init__( no_xml = ["text/plain", "text/calendar", "application/octet-stream"] expect_xml = any((content_type.startswith(x) for x in xml)) expect_no_xml = any((content_type.startswith(x) for x in no_xml)) - if content_type and not expect_xml and not expect_no_xml: + if ( + content_type + and not expect_xml + and not expect_no_xml + and response.status_code < 400 + ): error.weirdness(f"Unexpected content type: {content_type}") try: content_length = int(self.headers["Content-Length"]) @@ -350,11 +356,17 @@ def _expand_simple_prop( values = [] if proptag in props_found: prop_xml = props_found[proptag] - if prop_xml.items(): - from caldav.lib.debug import xmlstring - + for item in prop_xml.items(): + if proptag == "{urn:ietf:params:xml:ns:caldav}calendar-data": + if ( + item[0].lower().endswith("content-type") + and item[1].lower() == "text/calendar" + ): + continue + if item[0].lower().endswith("version") and item[1] in ("2", "2.0"): + continue log.error( - 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)}." + 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)}." ) if not xpath and len(prop_xml) == 0: if prop_xml.text: