summaryrefslogtreecommitdiff
path: root/requests/auth.py
diff options
context:
space:
mode:
authorMatthew Medal <matt.medal@gmail.com>2017-01-27 12:56:50 -0800
committerMatthew Medal <matt.medal@gmail.com>2017-01-27 12:56:50 -0800
commit8a58427d8aa73d6af81b6e5f6fd934b3386ef3de (patch)
tree210d18895c8660bf3e7c790dc842cd42634dae4b /requests/auth.py
parent23057dbc22d08ee831198f287d11d750f200e092 (diff)
downloadpython-requests-8a58427d8aa73d6af81b6e5f6fd934b3386ef3de.tar.gz
Only send HTTPDigestAuth on 4xx challenges
Resolves: #3772
Diffstat (limited to 'requests/auth.py')
-rw-r--r--requests/auth.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/requests/auth.py b/requests/auth.py
index 510846d6..762ac7e2 100644
--- a/requests/auth.py
+++ b/requests/auth.py
@@ -227,6 +227,12 @@ class HTTPDigestAuth(AuthBase):
:rtype: requests.Response
"""
+ # If response is not 4xx, do not auth
+ # See https://github.com/kennethreitz/requests/issues/3772
+ if not 400 <= r.status_code < 500:
+ self._thread_local.num_401_calls = 1
+ return r
+
if self._thread_local.pos is not None:
# Rewind the file position indicator of the body to where
# it was to resend the request.