From: Yossi Gottlieb Date: Sat, 27 Sep 2014 17:42:58 +0000 (+0300) Subject: A fix for #1979 repeat HTTP digest authentication after redirect. X-Git-Tag: v2.5.0~13^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c28da22e9c42e22b303bb07da434ce65e10c0cb2;p=services%2Fpython-requests.git A fix for #1979 repeat HTTP digest authentication after redirect. --- diff --git a/requests/auth.py b/requests/auth.py index 9b6426d..41be982 100644 --- a/requests/auth.py +++ b/requests/auth.py @@ -150,6 +150,14 @@ class HTTPDigestAuth(AuthBase): return 'Digest %s' % (base) + def handle_302(self, r, **kwargs): + """Reset num_401_calls counter on redirects.""" + try: + delattr(self, 'num_401_calls') + except AttributeError: + pass + return r + def handle_401(self, r, **kwargs): """Takes the given response and tries digest-auth, if needed.""" @@ -194,4 +202,5 @@ class HTTPDigestAuth(AuthBase): except AttributeError: pass r.register_hook('response', self.handle_401) + r.register_hook('response', self.handle_302) return r