From c4f013a6f999c2e945e00b1f052074b9c9377842 Mon Sep 17 00:00:00 2001 From: Douglas Morrison Date: Wed, 12 Oct 2011 13:21:09 +0000 Subject: [PATCH] Achieve full API compatibility. --- requests/api.py | 10 +++++----- requests/hooks.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/requests/api.py b/requests/api.py index 0417f81..dea4c1a 100644 --- a/requests/api.py +++ b/requests/api.py @@ -14,7 +14,7 @@ This module implements the Requests API. from ._config import get_config from .models import Request, Response from .status_codes import codes -from .hooks import dispatch_hooks +from .hooks import dispatch_hook from .utils import cookiejar_from_dict, header_expand @@ -73,13 +73,13 @@ def request(method, url, ) # Arguments manipulation hook. - args = dispatch_hooks('args', hooks, args) + args = dispatch_hook('args', hooks, args) # Create Request object. r = Request(**args) # Pre-request hook. - r = dispatch_hooks('pre_request', hooks, r) + r = dispatch_hook('pre_request', hooks, r) # Only construct the request (for async) if _return_request: @@ -90,10 +90,10 @@ def request(method, url, # TODO: Add these hooks inline. # Post-request hook. - r = dispatch_hooks('post_request', hooks, r) + r = dispatch_hook('post_request', hooks, r) # Response manipulation hook. - r.response = dispatch_hooks('response', hooks, r.response) + r.response = dispatch_hook('response', hooks, r.response) return r.response diff --git a/requests/hooks.py b/requests/hooks.py index cd113b9..36ec3c0 100644 --- a/requests/hooks.py +++ b/requests/hooks.py @@ -26,7 +26,7 @@ import warnings import collections -def dispatch_hooks(key, hooks, hook_data): +def dispatch_hook(key, hooks, hook_data): """Dipatches a hook dictionary on a given peice of data.""" hooks = (hooks or {}).get(key, []) -- 2.34.1