Skip to content
Myr

Merge pull request #1123 from andrewjesaitis/master

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

Fixes DigestAuth with Sessions

authored by Kenneth Reitz · committed by Kenneth Reitz · parents b6af862, 34268b1 · Browse files · 1 file+4 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+4 added−2 removed

  • other:+4 added−2 removed

1 file+4 added−2 removed

modified:requests/auth.py+4 added-2 removed
142 unmodified lines
143144 def handle_401(self, r):145 """Takes the given response and tries digest-auth, if needed."""146147 num_401_calls = r.request.hooks['response'].count(self.handle_401)147 num_401_calls = getattr(self, 'num_401_calls', 1)148 s_auth = r.headers.get('www-authenticate', '')149150 if 'digest' in s_auth.lower() and num_401_calls < 2:151152 setattr(self, 'num_401_calls', num_401_calls + 1)153 self.chal = parse_dict_header(s_auth.replace('Digest ', ''))154155 # Consume content and release the original connection156 # to allow our new request to reuse the same one.157 r.content158 r.raw.release_conn()158159 160 r.request.headers['Authorization'] = self.build_digest_header(r.request.method, r.request.url)161 _r = r.connection.send(r.request)162 _r.history.append(r)163164 return _r165166 setattr(self, 'num_401_calls', 1) 167 return r168169 def __call__(self, r):170 # If we have a saved nonce, skip the 401
4 unmodified lines