diff options
author | Ian Cordasco <sigmavirus24@users.noreply.github.com> | 2014-12-23 11:40:35 -0600 |
---|---|---|
committer | Ian Cordasco <sigmavirus24@users.noreply.github.com> | 2014-12-23 11:40:35 -0600 |
commit | eccbf4a4125199d353ec53e11dea56592270041a (patch) | |
tree | 2b4a55180bcf41641bd10191a378f7d2bc9e5081 | |
parent | bd3cf95e34aa49c8d764c899672048df107e0d70 (diff) | |
parent | 86c3ecfd341e4e86977317f03ae344d363c63e3a (diff) | |
download | python-requests-eccbf4a4125199d353ec53e11dea56592270041a.tar.gz |
Merge pull request #2389 from sigmavirus24/bug/fix-digest-auth
Fix bug in renegotiating a nonce with the server
-rw-r--r-- | requests/auth.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/requests/auth.py b/requests/auth.py index 618a902a..b950181d 100644 --- a/requests/auth.py +++ b/requests/auth.py @@ -67,6 +67,7 @@ class HTTPDigestAuth(AuthBase): self.nonce_count = 0 self.chal = {} self.pos = None + self.num_401_calls = 1 def build_digest_header(self, method, url): @@ -154,7 +155,7 @@ class HTTPDigestAuth(AuthBase): def handle_redirect(self, r, **kwargs): """Reset num_401_calls counter on redirects.""" if r.is_redirect: - setattr(self, 'num_401_calls', 1) + self.num_401_calls = 1 def handle_401(self, r, **kwargs): """Takes the given response and tries digest-auth, if needed.""" @@ -168,7 +169,7 @@ class HTTPDigestAuth(AuthBase): if 'digest' in s_auth.lower() and num_401_calls < 2: - setattr(self, 'num_401_calls', num_401_calls + 1) + self.num_401_calls += 1 pat = re.compile(r'digest ', flags=re.IGNORECASE) self.chal = parse_dict_header(pat.sub('', s_auth, count=1)) @@ -188,7 +189,7 @@ class HTTPDigestAuth(AuthBase): return _r - setattr(self, 'num_401_calls', num_401_calls + 1) + self.num_401_calls = 1 return r def __call__(self, r): |