Skip to content
Myr

Merge pull request #646 from mkomitee/hooks

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Allowing hooks to return responses that indicate errors

authored by Kenneth Reitz · committed by Kenneth Reitz · parents 355b971, 662c3ed · Browse files · 1 file+4 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+4 added−2 removed

  • other:+4 added−2 removed

1 file+4 added−2 removed

modified:requests/hooks.py+4 added-2 removed
28 unmodified lines
293031HOOKS = ('args', 'pre_request', 'pre_send', 'post_request', 'response')323333def dispatch_hook(key, hooks, hook_data):34 """Dispatches a hook dictionary on a given piece of data."""3536 hooks = hooks or dict()
5 unmodified lines
42 hooks = [hooks]4344 for hook in hooks:45 try:46 _hook_data = hook(hook_data)47 if _hook_data is not None:47 hook_data = hook(hook_data) or hook_data48 hook_data = _hook_data4950 except Exception:51 traceback.print_exc()5253 return hook_data