Expand docs note for async custom handler responses (#1916)
* Expand note for async custom handler responses Custom response handlers need to run `response.read()` before they can read the content of the response. However when using an AsyncClient this will produce an error of `RuntimeError: Attempted to call a sync iterator on an async stream.`. Took me some digging to figure out I just needed to use `response.aread()` here instead of `response.read()` so figured I would an MR with an expansion on the note for anyone else. Thanks! * Update advanced.md
This commit is contained in:
parent
62b1666dc6
commit
da8f959af0
@ -260,7 +260,7 @@ client = httpx.Client(event_hooks={'response': [raise_on_4xx_5xx]})
|
||||
should be read or not.
|
||||
|
||||
If you need access to the response body inside an event hook, you'll
|
||||
need to call `response.read()`.
|
||||
need to call `response.read()`, or for AsyncClients, `response.aread()`.
|
||||
|
||||
The hooks are also allowed to modify `request` and `response` objects.
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user