Permalink
Browse files

nonce_count fix

  • Loading branch information...
1 parent 66bacb0 commit 823cf3d7dd82d06944f3db11093b05a01bd7f5f1 @japerk committed Feb 19, 2012
Showing with 3 additions and 1 deletion.
  1. +3 −1 scrapy/contrib/downloadermiddleware/httpdigest.py
@@ -47,7 +47,9 @@ def authorize_request(self, request, spider):
if not info['qops']:
resp = hasher(':'.join([ha1, info['nonce'], ha2]))
else: # auth or auth-int
- nonce_count = self.nonce_counts[spider.name] + 1
+ # nonce_count must always increase
+ self.nonce_counts[spider.name] += 1
+ nonce_count = self.nonce_counts[spider.name]
nc = '%08x' % nonce_count # zero fill nonce_count so it's 8 digits long
# cnonce is a 16 char hash of a random string
cnonce = hasher(''.join([str(nonce_count), info['nonce'], time.ctime()] + [chr(random.randrange(32, 128)) for i in range(8)]).encode('utf-8'))[:16]

0 comments on commit 823cf3d

Please sign in to comment.