Return the body as a string instead of an iterable.

Heat REST API will never return an application/octet-stream so
this removes some dead code.

Change-Id: Ia0d35c898ba92924ba82d50f1cfde14b299569e5
This commit is contained in:
Steve Baker
2013-03-27 16:09:18 +13:00
parent 841ded0a5a
commit a5d6df0630

View File

@@ -156,14 +156,8 @@ class HTTPClient(object):
raise exc.CommunicationError(message=message)
body_iter = ResponseBodyIterator(resp)
# Read body into string if it isn't obviously image data
if resp.getheader('content-type', None) != 'application/octet-stream':
body_str = ''.join([chunk for chunk in body_iter])
self.log_http_response(resp, body_str)
body_iter = StringIO.StringIO(body_str)
else:
self.log_http_response(resp)
body_str = ''.join([chunk for chunk in body_iter])
self.log_http_response(resp, body_str)
if 400 <= resp.status < 600:
raise exc.from_response(resp, body_iter)
@@ -183,7 +177,7 @@ class HTTPClient(object):
elif resp.status == 300:
raise exc.from_response(resp, body_iter)
return resp, body_iter
return resp, body_str
def json_request(self, method, url, **kwargs):
kwargs.setdefault('headers', {})