Skip to content
Myr

Repurpose RedirectBodyUnavailable as RequestBodyUnavailable (#690)

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

authored by Florimond Manca · committed by GitHub · parent ff44d2d · Browse files · 4 files+18 added−13 removed
This commit

State

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

Diff stats

4 files+18 added−13 removed

  • tests:+2 added−2 removed
  • other:+16 added−11 removed

4 files+18 added−13 removed

modified:httpx/__init__.py+2 added-2 removed
15 unmodified lines
16 PoolTimeout,17 ProtocolError,18 ProxyError,19 ReadTimeout,20 RedirectBodyUnavailable,20 RedirectLoop,21 RequestBodyUnavailable,22 ResponseClosed,23 ResponseNotRead,24 StreamConsumed,25 TimeoutException,
36 unmodified lines
62 "NotRedirectResponse",63 "PoolTimeout",64 "ProtocolError",65 "ReadTimeout",66 "RedirectBodyUnavailable",66 "RedirectLoop",67 "RequestBodyUnavailable",68 "ResponseClosed",69 "ResponseNotRead",70 "StreamConsumed",71 "ProxyError",
13 unmodified lines
modified:httpx/client.py+7 added-2 removed
25 unmodified lines
26from .dispatch.proxy_http import HTTPProxy27from .exceptions import (28 HTTPError,29 InvalidURL,30 RedirectBodyUnavailable,30 RedirectLoop,31 RequestBodyUnavailable,32 TooManyRedirects,33)34from .models import (35 URL,
524 unmodified lines
560 Return the body that should be used for the redirect request.561 """562 if method != request.method and method == "GET":563 return None564565 if not request.stream.can_replay():565 raise RedirectBodyUnavailable()566 raise RequestBodyUnavailable(567 "Got a redirect response, but the request body was streaming "568 "and is no longer available."569 )570571 return request.stream572573 async def send_handling_auth(574 self, request: Request, auth: Auth, timeout: Timeout,
392 unmodified lines
modified:httpx/exceptions.py+7 added-7 removed
84 unmodified lines
85 Too many redirects.86 """878889class RedirectBodyUnavailable(RedirectError):90 """91 Got a redirect response, but the request body was streaming, and is92 no longer available.93 """949589class RedirectLoop(RedirectError):90 """91 Infinite redirect loop.92 """
16 unmodified lines
109 an invalid way.110 """111112113class RequestBodyUnavailable(StreamError):114 """115 Had to send the request again, but the request body was streaming, and is116 no longer available.117 """118119120class StreamConsumed(StreamError):121 """122 Attempted to read or stream response content, but the content has already123 been streamed.
36 unmodified lines
modified:tests/client/test_redirects.py+2 added-2 removed
5 unmodified lines
6from httpx import (7 URL,8 AsyncClient,9 NotRedirectResponse,10 RedirectBodyUnavailable,10 RedirectLoop,11 Request,12 RequestBodyUnavailable,13 Response,14 TooManyRedirects,15 codes,16)
275 unmodified lines
292293 async def streaming_body():294 yield b"Example request body"295296 with pytest.raises(RedirectBodyUnavailable):296 with pytest.raises(RequestBodyUnavailable):297 await client.post(url, data=streaming_body())298299300@pytest.mark.usefixtures("async_environment")
74 unmodified lines