From 6b76e58d6f1f0342b1f3937941a87f83ea799acb Mon Sep 17 00:00:00 2001 From: Eric Pendergrass Date: Wed, 1 May 2013 21:07:43 +0000 Subject: [PATCH] Fix for Bug #1167521, ceilometer client crashes with missing content type response pep8 compliance Change-Id: I7669c103fe3336aa82b289e04560192b44a186da --- ceilometerclient/common/http.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ceilometerclient/common/http.py b/ceilometerclient/common/http.py index ea4d64ff..85b01f9b 100644 --- a/ceilometerclient/common/http.py +++ b/ceilometerclient/common/http.py @@ -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)