Skip to content
Myr

hooks.py

This file

Path

requests/hooks.py

40 lines · 766 bytes · Python

Last changed by

Merge branch 'develop'Kenneth Reitzbefore adoption81d5997

History of this file

Take it

1# -*- coding: utf-8 -*-23"""4requests.hooks5~~~~~~~~~~~~~~67This module provides the capabilities for the Requests hooks system.89Available hooks:1011``args``:12    A dictionary of the arguments being sent to Request().1314``pre_request``:15    The Request object, directly before being sent.1617``post_request``:18    The Request object, directly after being sent.1920``response``:21    The response generated from a Request.2223"""2425import warnings262728def dispatch_hook(key, hooks, hook_data):29    """Dipatches a hook dictionary on a given peice of data."""3031    hooks = hooks or dict()3233    if key in hooks:34        try:35            return hooks.get(key).__call__(hook_data) or hook_data3637        except Exception, why:38            warnings.warn(str(why))3940    return hook_data