aboutsummaryrefslogtreecommitdiff
path: root/requests/auth.py
diff options
context:
space:
mode:
authorSVN-Git Migration <python-modules-team@lists.alioth.debian.org>2015-10-08 13:41:29 -0700
committerSVN-Git Migration <python-modules-team@lists.alioth.debian.org>2015-10-08 13:41:29 -0700
commit224200a9815f792f93632d03a38e4f0763ae69ef (patch)
tree161977259a7d8aa262aab60d7c8fce757ad3bb0f /requests/auth.py
parent653256249d44c67a0852d57a166948a9dc712ef4 (diff)
downloadpython-requests-224200a9815f792f93632d03a38e4f0763ae69ef.tar
python-requests-224200a9815f792f93632d03a38e4f0763ae69ef.tar.gz
Imported Upstream version 2.0.0
Diffstat (limited to 'requests/auth.py')
-rw-r--r--requests/auth.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/requests/auth.py b/requests/auth.py
index fab05cf..30529e2 100644
--- a/requests/auth.py
+++ b/requests/auth.py
@@ -18,7 +18,6 @@ from base64 import b64encode
from .compat import urlparse, str
from .utils import parse_dict_header
-
log = logging.getLogger(__name__)
CONTENT_TYPE_FORM_URLENCODED = 'application/x-www-form-urlencoded'
@@ -106,7 +105,9 @@ class HTTPDigestAuth(AuthBase):
A1 = '%s:%s:%s' % (self.username, realm, self.password)
A2 = '%s:%s' % (method, path)
- if qop == 'auth':
+ if qop is None:
+ respdig = KD(hash_utf8(A1), "%s:%s" % (nonce, hash_utf8(A2)))
+ elif qop == 'auth' or 'auth' in qop.split(','):
if nonce == self.last_nonce:
self.nonce_count += 1
else:
@@ -121,8 +122,6 @@ class HTTPDigestAuth(AuthBase):
cnonce = (hashlib.sha1(s).hexdigest()[:16])
noncebit = "%s:%s:%s:%s:%s" % (nonce, ncvalue, cnonce, qop, hash_utf8(A2))
respdig = KD(hash_utf8(A1), noncebit)
- elif qop is None:
- respdig = KD(hash_utf8(A1), "%s:%s" % (nonce, hash_utf8(A2)))
else:
# XXX handle auth-int.
return None
@@ -159,10 +158,14 @@ class HTTPDigestAuth(AuthBase):
# to allow our new request to reuse the same one.
r.content
r.raw.release_conn()
+ prep = r.request.copy()
+ prep.prepare_cookies(r.cookies)
- r.request.headers['Authorization'] = self.build_digest_header(r.request.method, r.request.url)
- _r = r.connection.send(r.request, **kwargs)
+ prep.headers['Authorization'] = self.build_digest_header(
+ prep.method, prep.url)
+ _r = r.connection.send(prep, **kwargs)
_r.history.append(r)
+ _r.request = prep
return _r