You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 660146e
Browse filesBrowse the repository at this point in the historyBrowse files
fix: map InvalidURL in build_request; clear TypeError for sync-stream middleware responses (#189)
build_request on both clients now raises TransportError for an invalid URL,
with the httpx2.InvalidURL as __cause__, like every other entry point.
When AsyncClient middleware returns an unread response with a sync stream,
send() and send_with_response() raise a TypeError that names the problem
instead of the RuntimeError from inside httpx2. Client gets the mirror check
for an async-stream response, which used to surface as a DecodeError.
Closes#175Closes#176
Copy file name to clipboardExpand all lines: docs/middleware.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -191,6 +191,8 @@ with Client(base_url="https://api.example.com", middleware=[add_request_id]) as
191
191
192
192
Sync and async middleware don't mix: pass `Middleware` to `Client` and `AsyncMiddleware` to `AsyncClient`. `Client` raises `TypeError` when you build it with async middleware, such as `AsyncRetry` or a function wrapped by `@async_before_request`.
193
193
194
+
The same split applies to a response your middleware builds itself. If its body comes from an iterator, use an async iterator on `AsyncClient` and a sync one on `Client`. With the wrong kind, a call with `response_model` raises `TypeError`.
195
+
194
196
## See also
195
197
196
198
-[Resilience](resilience.md): the built-in middleware and the order to compose them in.
0 commit comments