diff options
-rw-r--r-- | Lib/urllib/request.py | 6 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2020-02-06-05-33-52.bpo-39548.DF4FFe.rst | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index a6d350a..7fe5053 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -1138,7 +1138,9 @@ class AbstractDigestAuthHandler: req.selector) # NOTE: As per RFC 2617, when server sends "auth,auth-int", the client could use either `auth` # or `auth-int` to the response back. we use `auth` to send the response back. - if 'auth' in qop.split(','): + if qop is None: + respdig = KD(H(A1), "%s:%s" % (nonce, H(A2))) + elif 'auth' in qop.split(','): if nonce == self.last_nonce: self.nonce_count += 1 else: @@ -1148,8 +1150,6 @@ class AbstractDigestAuthHandler: cnonce = self.get_cnonce(nonce) noncebit = "%s:%s:%s:%s:%s" % (nonce, ncvalue, cnonce, 'auth', H(A2)) respdig = KD(H(A1), noncebit) - elif qop is None: - respdig = KD(H(A1), "%s:%s" % (nonce, H(A2))) else: # XXX handle auth-int. raise URLError("qop '%s' is not supported." % qop) diff --git a/Misc/NEWS.d/next/Library/2020-02-06-05-33-52.bpo-39548.DF4FFe.rst b/Misc/NEWS.d/next/Library/2020-02-06-05-33-52.bpo-39548.DF4FFe.rst new file mode 100644 index 0000000..4cf3248 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-02-06-05-33-52.bpo-39548.DF4FFe.rst @@ -0,0 +1,2 @@ +Fix handling of header in :class:`urllib.request.AbstractDigestAuthHandler` when the optional ``qop`` parameter +is not present. |