summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Brox <tobias@redpill-linpro.com>2021-09-17 10:11:40 +0200
committerTobias Brox <tobias@redpill-linpro.com>2021-09-17 10:11:40 +0200
commit53ac8dcdd6b611e3448dab0ea101b1f83d66aeb2 (patch)
treea01d2359721997ae1b806d77c3d24480e5badcd7
parentd4991907462a0afe446939dbf64f4bcb11e58368 (diff)
downloadpython-caldav-53ac8dcdd6b611e3448dab0ea101b1f83d66aeb2.zip
removing an error message, adding some stupid todo-things in the comments and closing https://github.com/python-caldav/caldav/issues/142
-rw-r--r--caldav/davclient.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/caldav/davclient.py b/caldav/davclient.py
index ea12e72..1261197 100644
--- a/caldav/davclient.py
+++ b/caldav/davclient.py
@@ -37,11 +37,11 @@ class DAVResponse:
log.debug("response headers: " + str(self.headers))
log.debug("response status: " + str(self.status))
- ## OPTIMIZE TODO: if content-type is text/xml, we could eventually do
- ## streaming into the etree library rather than first read the whole
- ## content into a string. (the line below just needs to be moved to
- ## the relevant if-pronges below)
self._raw = response.content
+
+ ## TODO: this if/else/elif could possibly be refactored, or we should
+ ## consider to do streaming into the xmltree library as originally
+ ## intended. It only makes sense for really huge payloads though.
if (self.headers.get('Content-Type', '').startswith('text/xml') or
self.headers.get('Content-Type', '').startswith('application/xml')):
try:
@@ -67,9 +67,12 @@ class DAVResponse:
## Logic here was moved when refactoring
pass
else:
- ## probably content-type was not given, i.e. iCloud does not seem to include those
- if 'Content-Type' in self.headers:
- log.error("unexpected content type from server: %s. %s" % (self.headers['Content-Type'], error.ERR_FRAGMENT))
+ ## Probably no content type given (iCloud). Some servers
+ ## give text/html as the default when no content is
+ ## delivered or on errors (ref
+ ## https://github.com/python-caldav/caldav/issues/142).
+ ## TODO: maybe just remove all of the code above in this if/else and let all
+ ## data be parsed through this code.
try:
self.tree = etree.XML(self._raw, parser=etree.XMLParser(remove_blank_text=True))
except: