Fix HTTPDigestAuth not to treat non-file as a file
authorAkira Kitada <akitada@gmail.com>
Wed, 12 Nov 2014 14:46:22 +0000 (23:46 +0900)
committerAkira Kitada <akitada@gmail.com>
Wed, 12 Nov 2014 15:51:35 +0000 (00:51 +0900)
Ensure pos is set to None when the body is not a file
so that HTTPDigestAuth detects the type of the body correctly.

requests/auth.py

index 010919f31f55f96948053941038031f42656b763..618a902a29d32fc4af8e99ba0ba0bb688b1c6c60 100644 (file)
@@ -198,7 +198,11 @@ class HTTPDigestAuth(AuthBase):
         try:
             self.pos = r.body.tell()
         except AttributeError:
-            pass
+            # In the case of HTTPDigestAuth being reused and the body of
+            # the previous request was a file-like object, pos has the
+            # file position of the previous body. Ensure it's set to
+            # None.
+            self.pos = None
         r.register_hook('response', self.handle_401)
         r.register_hook('response', self.handle_redirect)
         return r