From 67c505781cece96763b86c47967efb785f33b079 Mon Sep 17 00:00:00 2001 From: Akira Kitada Date: Wed, 12 Nov 2014 23:46:22 +0900 Subject: [PATCH] Fix HTTPDigestAuth not to treat non-file as a file 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 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/requests/auth.py b/requests/auth.py index 010919f..618a902 100644 --- a/requests/auth.py +++ b/requests/auth.py @@ -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 -- 2.34.1