mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
catch TooManyRedirects in safe_mode
This commit is contained in:
committed by
Shivaram Lingamneni
parent
7c5151e8e7
commit
2a27b123fd
+9
-1
@@ -631,7 +631,15 @@ class Request(object):
|
||||
else:
|
||||
raise
|
||||
|
||||
self._build_response(r)
|
||||
# build_response can throw TooManyRedirects
|
||||
try:
|
||||
self._build_response(r)
|
||||
except RequestException as e:
|
||||
if self.config.get('safe_mode', False):
|
||||
# In safe mode, catch the exception
|
||||
self.response.error = e
|
||||
else:
|
||||
raise
|
||||
|
||||
# Response manipulation hook.
|
||||
self.response = dispatch_hook('response', self.hooks, self.response)
|
||||
|
||||
Reference in New Issue
Block a user