Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar_network/toolkit/http.py
diff options
context:
space:
mode:
Diffstat (limited to 'sugar_network/toolkit/http.py')
-rw-r--r--sugar_network/toolkit/http.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/sugar_network/toolkit/http.py b/sugar_network/toolkit/http.py
index d57d3ce..cadf64c 100644
--- a/sugar_network/toolkit/http.py
+++ b/sugar_network/toolkit/http.py
@@ -85,12 +85,24 @@ class NotFound(Status):
status_code = 404
+class BadGateway(Status):
+
+ status = '502 Bad Gateway'
+ status_code = 502
+
+
class ServiceUnavailable(Status):
status = '503 Service Unavailable'
status_code = 503
+class GatewayTimeout(Status):
+
+ status = '504 Gateway Timeout'
+ status_code = 504
+
+
def download(url, dst_path=None):
# TODO (?) Reuse HTTP session
return Connection().download(url, dst_path)
@@ -233,12 +245,8 @@ class Connection(object):
continue
error = content or reply.headers.get('x-sn-error') or \
'No error message provided'
- _logger.debug('Request failed, method=%s path=%r params=%r '
- 'headers=%r status_code=%s error=%s',
- method, path, params, headers, reply.status_code,
- '\n' + error)
cls = _FORWARD_STATUSES.get(reply.status_code, RuntimeError)
- raise cls(error)
+ raise cls, error, sys.exc_info()[2]
break
return reply
@@ -385,5 +393,7 @@ _FORWARD_STATUSES = {
BadRequest.status_code: BadRequest,
Forbidden.status_code: Forbidden,
NotFound.status_code: NotFound,
+ BadGateway.status_code: BadGateway,
ServiceUnavailable.status_code: ServiceUnavailable,
+ GatewayTimeout.status_code: GatewayTimeout,
}