summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSenthil Kumaran <orsenthil@gmail.com>2009-11-15 08:36:20 (GMT)
committerSenthil Kumaran <orsenthil@gmail.com>2009-11-15 08:36:20 (GMT)
commit20eb4f078237e8bc7a5ac970714cee4d8feb7a09 (patch)
tree44d746c892a44bf189225341b0c4cf146c1f9e4b
parent49868cb686954e57a6ab6bfea2cefeefb86305b1 (diff)
downloadcpython-20eb4f078237e8bc7a5ac970714cee4d8feb7a09.zip
cpython-20eb4f078237e8bc7a5ac970714cee4d8feb7a09.tar.gz
cpython-20eb4f078237e8bc7a5ac970714cee4d8feb7a09.tar.bz2
Fix for Issue4683 - urllib2.HTTPDigestAuthHandler fails on third hostname?.
Resolution: Reset the nonce value for each unique nonce (as per RFC 2617)
-rw-r--r--Lib/urllib2.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/urllib2.py b/Lib/urllib2.py
index 2d73475..8dcf8da 100644
--- a/Lib/urllib2.py
+++ b/Lib/urllib2.py
@@ -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':
- self.nonce_count += 1
+ 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))