mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Merge of maxcountryman
This commit is contained in:
@@ -87,3 +87,4 @@ Patches and Suggestions
|
||||
- Brendan Maguire <maguire.brendan@gmail.com>
|
||||
- Chris Dary
|
||||
- Danver Braganza <danverbraganza@gmail.com>
|
||||
- Max Countryman
|
||||
|
||||
@@ -14,6 +14,7 @@ class RequestException(RuntimeError):
|
||||
|
||||
class HTTPError(RequestException):
|
||||
"""An HTTP error occurred."""
|
||||
response = None
|
||||
|
||||
class ConnectionError(RequestException):
|
||||
"""A Connection error occurred."""
|
||||
|
||||
+10
-3
@@ -800,10 +800,17 @@ class Response(object):
|
||||
raise self.error
|
||||
|
||||
if (self.status_code >= 300) and (self.status_code < 400) and not allow_redirects:
|
||||
raise HTTPError('%s Redirection' % self.status_code)
|
||||
http_error = HTTPError('%s Redirection' % self.status_code)
|
||||
http_error.response = self
|
||||
raise http_error
|
||||
|
||||
elif (self.status_code >= 400) and (self.status_code < 500):
|
||||
raise HTTPError('%s Client Error' % self.status_code)
|
||||
http_error = HTTPError('%s Client Error' % self.status_code)
|
||||
http_error.response = self
|
||||
raise http_error
|
||||
|
||||
|
||||
elif (self.status_code >= 500) and (self.status_code < 600):
|
||||
raise HTTPError('%s Server Error' % self.status_code)
|
||||
http_error = HTTPError('%s Server Error' % self.status_code)
|
||||
http_error.response = self
|
||||
raise http_error
|
||||
|
||||
Reference in New Issue
Block a user