From 587eb193ddbc2dfc10c2bdbf1718cd2267a0e77f Mon Sep 17 00:00:00 2001 From: Paul van der Linden Date: Wed, 18 Mar 2015 11:29:18 +0000 Subject: [PATCH] fix resolve redirect to pass all original arguments --- AUTHORS.rst | 3 ++- requests/sessions.py | 14 +++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/AUTHORS.rst b/AUTHORS.rst index 8a40bd970d..2858680932 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -160,4 +160,5 @@ Patches and Suggestions - Scott Sadler (`@ssadler `_) - Arthur Darcet (`@arthurdarcet `_) - Ulrich Petri (`@ulope `_) -- Muhammad Yasoob Ullah Khalid (`@yasoob `_) \ No newline at end of file +- Muhammad Yasoob Ullah Khalid (`@yasoob `_) +- Paul van der Linden (`@pvanderlinden `_) diff --git a/requests/sessions.py b/requests/sessions.py index ef3f22bc5c..820919ee88 100644 --- a/requests/sessions.py +++ b/requests/sessions.py @@ -90,7 +90,7 @@ def merge_hooks(request_hooks, session_hooks, dict_class=OrderedDict): class SessionRedirectMixin(object): def resolve_redirects(self, resp, req, stream=False, timeout=None, - verify=True, cert=None, proxies=None): + verify=True, cert=None, proxies=None, **adapter_kwargs): """Receives a Response. Returns a generator of Responses.""" i = 0 @@ -193,6 +193,7 @@ def resolve_redirects(self, resp, req, stream=False, timeout=None, cert=cert, proxies=proxies, allow_redirects=False, + **adapter_kwargs ) extract_cookies_to_jar(self.cookies, prepared_request, resp.raw) @@ -560,10 +561,6 @@ def send(self, request, **kwargs): # Set up variables needed for resolve_redirects and dispatching of hooks allow_redirects = kwargs.pop('allow_redirects', True) stream = kwargs.get('stream') - timeout = kwargs.get('timeout') - verify = kwargs.get('verify') - cert = kwargs.get('cert') - proxies = kwargs.get('proxies') hooks = request.hooks # Get the appropriate adapter to use @@ -591,12 +588,7 @@ def send(self, request, **kwargs): extract_cookies_to_jar(self.cookies, request, r.raw) # Redirect resolving generator. - gen = self.resolve_redirects(r, request, - stream=stream, - timeout=timeout, - verify=verify, - cert=cert, - proxies=proxies) + gen = self.resolve_redirects(r, request, **kwargs) # Resolve redirects if allowed. history = [resp for resp in gen] if allow_redirects else []