summaryrefslogtreecommitdiff
path: root/keystoneclient/client.py
diff options
context:
space:
mode:
authorLin Hua Cheng <lin-hua.cheng@hp.com>2013-03-13 20:59:03 -0700
committerLin Hua Cheng <lin-hua.cheng@hp.com>2013-04-17 22:02:30 -0700
commitd3583cad27b1f667965573a737e4c6e5971e4285 (patch)
treedace675656fa9d8ac6f2fcb0b8b5c0db4c0eb1f4 /keystoneclient/client.py
parentaaf3aa977fafe1f4b6d4a01f82b3ce532a39f95a (diff)
downloadpython-keystoneclient-d3583cad27b1f667965573a737e4c6e5971e4285.tar.gz
Pass json object when invoking exception handler.
Fixes bug 1154753. Change-Id: I6ca7c758d42e8586c8adf2529ce5362108a57a56
Diffstat (limited to 'keystoneclient/client.py')
-rw-r--r--keystoneclient/client.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/keystoneclient/client.py b/keystoneclient/client.py
index fb5c6db..50203c3 100644
--- a/keystoneclient/client.py
+++ b/keystoneclient/client.py
@@ -359,19 +359,10 @@ class HTTPClient(object):
self.http_log_resp(resp)
- if resp.status_code >= 400:
- _logger.debug(
- "Request returned failure status: %s",
- resp.status_code)
- raise exceptions.from_response(resp, resp.text)
- elif resp.status_code in (301, 302, 305):
- # Redirected. Reissue the request to the new location.
- return self.request(resp.headers['location'], method, **kwargs)
-
if resp.text:
try:
body = json.loads(resp.text)
- except ValueError:
+ except (ValueError, TypeError):
body = None
_logger.debug("Could not decode JSON from body: %s"
% resp.text)
@@ -379,6 +370,15 @@ class HTTPClient(object):
_logger.debug("No body was returned.")
body = None
+ if resp.status_code >= 400:
+ _logger.debug(
+ "Request returned failure status: %s",
+ resp.status_code)
+ raise exceptions.from_response(resp, body or resp.text)
+ elif resp.status_code in (301, 302, 305):
+ # Redirected. Reissue the request to the new location.
+ return self.request(resp.headers['location'], method, **kwargs)
+
return resp, body
def _cs_request(self, url, method, **kwargs):