Fix for Bug #1167521, ceilometer client crashes with missing content type response

pep8 compliance

Change-Id: I7669c103fe3336aa82b289e04560192b44a186da
This commit is contained in:
Eric Pendergrass
2013-05-01 21:07:43 +00:00
parent 888d63aaa0
commit 6b76e58d6f

View File

@@ -180,8 +180,12 @@ class HTTPClient(object):
kwargs['body'] = json.dumps(kwargs['body'])
resp, body_iter = self._http_request(url, method, **kwargs)
content_type = resp.getheader('content-type', None)
if 'application/json' in resp.getheader('content-type', None):
if resp.status == 204 or resp.status == 205 or content_type is None:
return resp, list()
if 'application/json' in content_type:
body = ''.join([chunk for chunk in body_iter])
try:
body = json.loads(body)