Release connection in digest auth 401 handler to allow the connection to be reused.
authorPeter Montagner <zigmonty@gmail.com>
Sat, 18 Aug 2012 02:53:57 +0000 (12:53 +1000)
committerPeter Montagner <zigmonty@gmail.com>
Sat, 18 Aug 2012 02:53:57 +0000 (12:53 +1000)
requests/auth.py

index 38dd874..e5176bf 100644 (file)
@@ -227,6 +227,11 @@ class HTTPDigestAuth(AuthBase):
             if qop:
                 base += ', qop=auth, nc=%s, cnonce="%s"' % (ncvalue, cnonce)
 
+            # Consume content and release the original connection 
+            # to allow our new request to reuse the same one.
+            r.content
+            r.raw.release_conn()
+
             r.request.headers['Authorization'] = 'Digest %s' % (base)
             r.request.send(anyway=True)
             _r = r.request.response