Skip to content
Myr

Fixes repeated 401s when using DigestAuth with a session

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Andrew Jesaitis · committed by Andrew Jesaitis · parent b7242a1 · Browse files · 1 file+2 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+2 added−2 removed

  • other:+2 added−2 removed

1 file+2 added−2 removed

modified:requests/auth.py+2 added-2 removed
137 unmodified lines
138 return 'Digest %s' % (base)139140 def handle_401(self, r):141 """Takes the given response and tries digest-auth, if needed."""142143 num_401_calls = r.request.hooks['response'].count(self.handle_401)142 num_401_calls = getattr(r.request, 'num_401_calls', 1) 143 s_auth = r.headers.get('www-authenticate', '')144145 if 'digest' in s_auth.lower() and num_401_calls < 2:146
4 unmodified lines
151 r.content152 r.raw.release_conn()153154 r.request.headers['Authorization'] = self.build_digest_header(r.request.method, r.request.url)155 r.request.num_401_calls = num_401_calls + 1156 _r = r.connection.send(r.request)157 _r.history.append(r)158159 return _r
9 unmodified lines