mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Merge pull request #646 from mkomitee/hooks
Allowing hooks to return responses that indicate errors
This commit is contained in:
+4
-2
@@ -30,7 +30,6 @@ import traceback
|
||||
|
||||
HOOKS = ('args', 'pre_request', 'pre_send', 'post_request', 'response')
|
||||
|
||||
|
||||
def dispatch_hook(key, hooks, hook_data):
|
||||
"""Dispatches a hook dictionary on a given piece of data."""
|
||||
|
||||
@@ -44,7 +43,10 @@ def dispatch_hook(key, hooks, hook_data):
|
||||
|
||||
for hook in hooks:
|
||||
try:
|
||||
hook_data = hook(hook_data) or hook_data
|
||||
_hook_data = hook(hook_data)
|
||||
if _hook_data is not None:
|
||||
hook_data = _hook_data
|
||||
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user