Skip to content
Myr

Merge pull request #1760 from akitada/fix-hangs-on-streaming-uploads

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

Fix hangs on streaming uploads with HTTPDigestAuth

authored by Kenneth Reitz · committed by Kenneth Reitz · parents e5b9ae1, 3a9d9f2 · Browse files · 1 file+9 added−0 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+9 added−0 removed

  • other:+9 added−0 removed

1 file+9 added−0 removed

modified:requests/auth.py+9 added
61 unmodified lines
62 self.password = password63 self.last_nonce = ''64 self.nonce_count = 065 self.chal = {}66 self.pos = None6768 def build_digest_header(self, method, url):6970 realm = self.chal['realm']
79 unmodified lines
150151 def handle_401(self, r, **kwargs):152 """Takes the given response and tries digest-auth, if needed."""153154 if self.pos is not None:155 # Rewind the file position indicator of the body to where156 # it was to resend the request.157 r.request.body.seek(self.pos)158 num_401_calls = getattr(self, 'num_401_calls', 1)159 s_auth = r.headers.get('www-authenticate', '')160161 if 'digest' in s_auth.lower() and num_401_calls < 2:
23 unmodified lines
185 def __call__(self, r):186 # If we have a saved nonce, skip the 401187 if self.last_nonce:188 r.headers['Authorization'] = self.build_digest_header(r.method, r.url)189 try:190 self.pos = r.body.tell()191 except AttributeError:192 pass193 r.register_hook('response', self.handle_401)194 return r