Skip to content

Commit

Permalink
nonce_count fix
Browse files Browse the repository at this point in the history
  • Loading branch information
japerk committed Feb 19, 2012
1 parent 66bacb0 commit 823cf3d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion scrapy/contrib/downloadermiddleware/httpdigest.py
Expand Up @@ -47,7 +47,9 @@ def authorize_request(self, request, spider):
if not info['qops']: if not info['qops']:
resp = hasher(':'.join([ha1, info['nonce'], ha2])) resp = hasher(':'.join([ha1, info['nonce'], ha2]))
else: # auth or auth-int 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 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 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] cnonce = hasher(''.join([str(nonce_count), info['nonce'], time.ctime()] + [chr(random.randrange(32, 128)) for i in range(8)]).encode('utf-8'))[:16]
Expand Down

0 comments on commit 823cf3d

Please sign in to comment.