Skip to content
Myr

Moves num_401_calls counter to HTTPDigestAuth

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 03893d9 · Browse files · 1 file+5 added−3 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+5 added−3 removed

  • other:+5 added−3 removed

1 file+5 added−3 removed

modified:requests/auth.py+5 added-3 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."""142142 num_401_calls = getattr(r.request, 'num_401_calls', 1) 143 num_401_calls = getattr(self, 'num_401_calls', 1)144 s_auth = r.headers.get('www-authenticate', '')145146 if 'digest' in s_auth.lower() and num_401_calls < 2:147148 setattr(self, 'num_401_calls', num_401_calls + 1)149 self.chal = parse_dict_header(s_auth.replace('Digest ', ''))150151 # Consume content and release the original connection152 # to allow our new request to reuse the same one.153 r.content154 r.raw.release_conn()153155 156 r.request.headers['Authorization'] = self.build_digest_header(r.request.method, r.request.url)155 r.request.num_401_calls = num_401_calls + 1157 _r = r.connection.send(r.request)158 _r.history.append(r)159160 return _r161162 setattr(self, 'num_401_calls', 1) 163 return r164165 def __call__(self, r):166 # If we have a saved nonce, skip the 401
4 unmodified lines