From 6b65a6840ce5013eafb3b4c168ecab8d9958a0d3 Mon Sep 17 00:00:00 2001 From: Brad Allred Date: Fri, 30 Dec 2016 13:50:54 -0700 Subject: [PATCH] fix exception when response lacks content-type not all APIs respond with a content-type header specifically actions such as DELETE may not have a body --- siesta/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/siesta/__init__.py b/siesta/__init__.py index c655f85..04f353b 100644 --- a/siesta/__init__.py +++ b/siesta/__init__.py @@ -220,8 +220,8 @@ def _getresponse(self, method, url, body={}, headers={}, meta={}): resource = Resource(uri=urlparse(location).path, api=self.api).get() return resource #logging.info("resp.getheader(): %s" % resp.getheader('content-type')) - m = re.match('^([^;]*)(?:;\s*charset=(.*))?$', - resp.getheader('content-type')) + type = resp.getheader('content-type', '') + m = re.match('^([^;]*)(?:;\s*charset=(.*))?$', type) #logging.info("response: %s" % resp) if m == None: