Use user supplied options when resending authenticated requests

Hooks sometimes have to send requests (e.g. when responding to a 401 during
authentication).

All keyword arguments should be passed along when hooks are dispatched so that
if a user wanted to use a timeout, stream, specify a cert location with the
verify flag, etc, their specification can be followed.
This commit is contained in:
Michael Komitee
2013-02-13 19:11:38 -05:00
parent f73bda06e9
commit d0285fac42
3 changed files with 5 additions and 5 deletions
+2 -2
View File
@@ -142,7 +142,7 @@ class HTTPDigestAuth(AuthBase):
return 'Digest %s' % (base)
def handle_401(self, r):
def handle_401(self, r, **kwargs):
"""Takes the given response and tries digest-auth, if needed."""
num_401_calls = getattr(self, 'num_401_calls', 1)
@@ -159,7 +159,7 @@ class HTTPDigestAuth(AuthBase):
r.raw.release_conn()
r.request.headers['Authorization'] = self.build_digest_header(r.request.method, r.request.url)
_r = r.connection.send(r.request)
_r = r.connection.send(r.request, **kwargs)
_r.history.append(r)
return _r
+2 -2
View File
@@ -26,7 +26,7 @@ def default_hooks():
# TODO: response is the only one
def dispatch_hook(key, hooks, hook_data):
def dispatch_hook(key, hooks, hook_data, **kwargs):
"""Dispatches a hook dictionary on a given piece of data."""
hooks = hooks or dict()
@@ -38,7 +38,7 @@ def dispatch_hook(key, hooks, hook_data):
hooks = [hooks]
for hook in hooks:
_hook_data = hook(hook_data)
_hook_data = hook(hook_data, **kwargs)
if _hook_data is not None:
hook_data = _hook_data
+1 -1
View File
@@ -415,7 +415,7 @@ class Session(SessionRedirectMixin):
r.elapsed = datetime.utcnow() - start
# Response manipulation hooks
r = dispatch_hook('response', hooks, r)
r = dispatch_hook('response', hooks, r, **kwargs)
# Redirect resolving generator.
gen = self.resolve_redirects(r, request, stream=stream,