Merge "Catches HTTP 300 while printing responses"

This commit is contained in:
Jenkins
2012-09-10 23:36:21 +00:00
committed by Gerrit Code Review
2 changed files with 12 additions and 0 deletions

View File

@@ -159,6 +159,8 @@ class HTTPClient(object):
elif resp.status in (301, 302, 305): elif resp.status in (301, 302, 305):
# Redirected. Reissue the request to the new location. # Redirected. Reissue the request to the new location.
return self._http_request(resp['location'], method, **kwargs) return self._http_request(resp['location'], method, **kwargs)
elif resp.status == 300:
raise exc.from_response(resp)
return resp, body_iter return resp, body_iter

View File

@@ -52,6 +52,16 @@ class HTTPException(ClientException):
return "%s (HTTP %s)" % (self.__class__.__name__, self.code) return "%s (HTTP %s)" % (self.__class__.__name__, self.code)
class HTTPMultipleChoices(HTTPException):
code = 300
def __str__(self):
self.details = ("Requested version of OpenStack Images API is not"
"available.")
return "%s (HTTP %s) %s" % (self.__class__.__name__, self.code,
self.details)
class BadRequest(HTTPException): class BadRequest(HTTPException):
"""DEPRECATED""" """DEPRECATED"""
code = 400 code = 400