Path: blob/master/venv/Lib/site-packages/requests/hooks.py
811 views
# -*- coding: utf-8 -*-12"""3requests.hooks4~~~~~~~~~~~~~~56This module provides the capabilities for the Requests hooks system.78Available hooks:910``response``:11The response generated from a Request.12"""13HOOKS = ['response']141516def default_hooks():17return {event: [] for event in HOOKS}1819# TODO: response is the only one202122def dispatch_hook(key, hooks, hook_data, **kwargs):23"""Dispatches a hook dictionary on a given piece of data."""24hooks = hooks or {}25hooks = hooks.get(key)26if hooks:27if hasattr(hooks, '__call__'):28hooks = [hooks]29for hook in hooks:30_hook_data = hook(hook_data, **kwargs)31if _hook_data is not None:32hook_data = _hook_data33return hook_data343536