A fix for #1979 repeat HTTP digest authentication after redirect.

This commit is contained in:
Yossi Gottlieb
2014-09-27 20:42:58 +03:00
parent a718a81d27
commit c28da22e9c
+9
View File
@@ -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