Treat HTTP code 400 and above as error.

Fixes bug 1116559.

Change-Id: I4b12176599686f7e545b63c8e54cf9da6a1f963e
This commit is contained in:
Lin Hua Cheng
2013-02-05 11:17:53 -08:00
parent 76c7b08645
commit 382441a9f1
2 changed files with 10 additions and 1 deletions

View File

@@ -341,7 +341,7 @@ class HTTPClient(object):
self.http_log_resp(resp) self.http_log_resp(resp)
if resp.status_code in (400, 401, 403, 404, 408, 409, 413, 500, 501): if resp.status_code >= 400:
_logger.debug( _logger.debug(
"Request returned failure status: %s", "Request returned failure status: %s",
resp.status_code) resp.status_code)

View File

@@ -79,6 +79,14 @@ class NotFound(ClientException):
message = "Not found" message = "Not found"
class MethodNotAllowed(ClientException):
"""
HTTP 405 - Method not allowed
"""
http_status = 405
message = "Method not allowed"
class Conflict(ClientException): class Conflict(ClientException):
""" """
HTTP 409 - Conflict HTTP 409 - Conflict
@@ -122,6 +130,7 @@ _code_map = dict((c.http_status, c) for c in [BadRequest,
Unauthorized, Unauthorized,
Forbidden, Forbidden,
NotFound, NotFound,
MethodNotAllowed,
OverLimit, OverLimit,
HTTPNotImplemented, HTTPNotImplemented,
ServiceUnavailable]) ServiceUnavailable])