Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/requests/hooks.py: 21%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2requests.hooks
3~~~~~~~~~~~~~~
5This module provides the capabilities for the Requests hooks system.
7Available hooks:
9``response``:
10 The response generated from a Request.
11"""
12HOOKS = ["response"]
15def default_hooks():
16 return {event: [] for event in HOOKS}
19# TODO: response is the only one
22def dispatch_hook(key, hooks, hook_data, **kwargs):
23 """Dispatches a hook dictionary on a given piece of data."""
24 hooks = hooks or {}
25 hooks = hooks.get(key)
26 if hooks:
27 if hasattr(hooks, "__call__"):
28 hooks = [hooks]
29 for hook in hooks:
30 _hook_data = hook(hook_data, **kwargs)
31 if _hook_data is not None:
32 hook_data = _hook_data
33 return hook_data