mirror of https://github.com/python/cpython
Fix for Issue4683 - urllib2.HTTPDigestAuthHandler fails on third hostname?.
Resolution: Reset the nonce value for each unique nonce (as per RFC 2617)
This commit is contained in:
parent
49868cb686
commit
20eb4f0782
|
@ -901,6 +901,7 @@ class AbstractDigestAuthHandler:
|
|||
self.add_password = self.passwd.add_password
|
||||
self.retried = 0
|
||||
self.nonce_count = 0
|
||||
self.last_nonce = None
|
||||
|
||||
def reset_retry_count(self):
|
||||
self.retried = 0
|
||||
|
@ -975,7 +976,12 @@ class AbstractDigestAuthHandler:
|
|||
# XXX selector: what about proxies and full urls
|
||||
req.get_selector())
|
||||
if qop == 'auth':
|
||||
if nonce == self.last_nonce:
|
||||
self.nonce_count += 1
|
||||
else:
|
||||
self.nonce_count = 1
|
||||
self.last_nonce = nonce
|
||||
|
||||
ncvalue = '%08x' % self.nonce_count
|
||||
cnonce = self.get_cnonce(nonce)
|
||||
noncebit = "%s:%s:%s:%s:%s" % (nonce, ncvalue, cnonce, qop, H(A2))
|
||||
|
|
Loading…
Reference in New Issue