diff options
| author | littleblack111 <jerrylam110209@gmail.com> | 2023-08-15 22:43:44 +0800 |
|---|---|---|
| committer | littleblack111 <jerrylam110209@gmail.com> | 2023-08-15 22:43:44 +0800 |
| commit | 770042d3e7ef8ed49a353ba7e481c25cbaab793a (patch) | |
| tree | 3f4f0bf4ba9739f57636c3e7a92d34c5b352c67b /lib/python3.11/site-packages/requests/hooks.py | |
| parent | 291a5cbf3bef71418b9260e7336ea3714af0629b (diff) | |
updated
Diffstat (limited to 'lib/python3.11/site-packages/requests/hooks.py')
| -rw-r--r-- | lib/python3.11/site-packages/requests/hooks.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/python3.11/site-packages/requests/hooks.py b/lib/python3.11/site-packages/requests/hooks.py new file mode 100644 index 0000000..d181ba2 --- /dev/null +++ b/lib/python3.11/site-packages/requests/hooks.py @@ -0,0 +1,33 @@ +""" +requests.hooks +~~~~~~~~~~~~~~ + +This module provides the capabilities for the Requests hooks system. + +Available hooks: + +``response``: + The response generated from a Request. +""" +HOOKS = ["response"] + + +def default_hooks(): + return {event: [] for event in HOOKS} + + +# TODO: response is the only one + + +def dispatch_hook(key, hooks, hook_data, **kwargs): + """Dispatches a hook dictionary on a given piece of data.""" + hooks = hooks or {} + hooks = hooks.get(key) + if hooks: + if hasattr(hooks, "__call__"): + hooks = [hooks] + for hook in hooks: + _hook_data = hook(hook_data, **kwargs) + if _hook_data is not None: + hook_data = _hook_data + return hook_data |
