From: Cory Benfield Date: Fri, 29 Nov 2013 08:37:25 +0000 (+0000) Subject: Quote qop values in digest auth. X-Git-Tag: v2.1.0~9^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fecb35a08ec77d6392bdc609ab1ea21943e40228;p=services%2Fpython-requests.git Quote qop values in digest auth. --- diff --git a/requests/auth.py b/requests/auth.py index a3de123..f87087d 100644 --- a/requests/auth.py +++ b/requests/auth.py @@ -105,7 +105,7 @@ class HTTPDigestAuth(AuthBase): A1 = '%s:%s:%s' % (self.username, realm, self.password) A2 = '%s:%s' % (method, path) - + HA1 = hash_utf8(A1) HA2 = hash_utf8(A2) @@ -144,7 +144,7 @@ class HTTPDigestAuth(AuthBase): if entdig: base += ', digest="%s"' % entdig if qop: - base += ', qop=auth, nc=%s, cnonce="%s"' % (ncvalue, cnonce) + base += ', qop="auth", nc=%s, cnonce="%s"' % (ncvalue, cnonce) return 'Digest %s' % (base) diff --git a/test_requests.py b/test_requests.py index 3b67395..4035695 100755 --- a/test_requests.py +++ b/test_requests.py @@ -320,6 +320,14 @@ class RequestsTestCase(unittest.TestCase): r = s.get(url) assert r.status_code == 401 + def test_DIGESTAUTH_QUOTES_QOP_VALUE(self): + + auth = HTTPDigestAuth('user', 'pass') + url = httpbin('digest-auth', 'auth', 'user', 'pass') + + r = requests.get(url, auth=auth) + assert '"auth"' in r.request.headers['Authorization'] + def test_POSTBIN_GET_POST_FILES(self): url = httpbin('post')