Merge "Decode content before checking"
This commit is contained in:
commit
565c05cce1
|
@ -221,10 +221,10 @@ class HTTPClient(object):
|
|||
raise exc.CommunicationError(message=message)
|
||||
|
||||
self.log_http_response(resp)
|
||||
|
||||
txt_content = encodeutils.safe_decode(resp.content, 'utf-8')
|
||||
if not ('X-Auth-Key' in kwargs['headers']) and (
|
||||
resp.status_code == 401 or
|
||||
(resp.status_code == 500 and "(HTTP 401)" in resp.content)):
|
||||
(resp.status_code == 500 and "(HTTP 401)" in txt_content)):
|
||||
raise exc.HTTPUnauthorized(_("Authentication failed: %s")
|
||||
% resp.content)
|
||||
elif 400 <= resp.status_code < 600:
|
||||
|
|
|
@ -132,7 +132,7 @@ class HttpClientTest(testtools.TestCase):
|
|||
fake500 = fakes.FakeHTTPResponse(
|
||||
500, 'ERROR',
|
||||
{'content-type': 'application/octet-stream'},
|
||||
'(HTTP 401)')
|
||||
b'(HTTP 401)')
|
||||
|
||||
# no token or credentials
|
||||
mock_request.return_value = fake500
|
||||
|
|
Loading…
Reference in New Issue