Skip to content
Myr

Include 'request' on TooManyRedirect and RequestBodyUnavailable (#1077)

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

authored by Tom Christie · committed by GitHub · parent 01287ba · Browse files · 2 files+14 added−4 removed
This commit

State

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

Diff stats

2 files+14 added−4 removed

  • other:+14 added−4 removed

2 files+14 added−4 removed

modified:httpx/_auth.py+6 added-1 removed
98 unmodified lines
99 self.password = to_bytes(password)100101 def auth_flow(self, request: Request) -> typing.Generator[Request, Response, None]:102 if not request.stream.can_replay():103 raise RequestBodyUnavailable("Request body is no longer available.")103 raise RequestBodyUnavailable(104 "Cannot use digest auth with streaming requests that are unable "105 "to replay the request body if a second request is required.",106 request=request,107 )108109 response = yield request110111 if response.status_code != 401 or "www-authenticate" not in response.headers:112 # If the response is not a 401 WWW-Authenticate, then we don't
143 unmodified lines
modified:httpx/_client.py+8 added-3 removed
374 unmodified lines
375376 if not request.stream.can_replay():377 raise RequestBodyUnavailable(378 "Got a redirect response, but the request body was streaming "379 "and is no longer available."379 "and is no longer available.",380 request=request,381 )382383 return request.stream384
243 unmodified lines
628 history = []629630 while True:631 if len(history) > self.max_redirects:631 raise TooManyRedirects()632 raise TooManyRedirects(633 "Exceeded maximum allowed redirects.", request=request634 )635636 response = self._send_handling_auth(637 request, auth=auth, timeout=timeout, history=history638 )
522 unmodified lines
1161 history = []11621163 while True:1164 if len(history) > self.max_redirects:1162 raise TooManyRedirects()1165 raise TooManyRedirects(1166 "Exceeded maximum allowed redirects.", request=request1167 )11681169 response = await self._send_handling_auth(1170 request, auth=auth, timeout=timeout, history=history1171 )
337 unmodified lines