Skip to content
Myr

Expand docs note for async custom handler responses (#1916)

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

* 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

authored by Tyler Chamberlain · committed by GitHub · parent 62b1666 · Browse files · 1 file+1 added−1 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+1 added−1 removed

  • other:+1 added−1 removed

1 file+1 added−1 removed

modified:docs/advanced.md+1 added-1 removed
258 unmodified lines
259 Response event hooks are called before determining if the response body260 should be read or not.261262 If you need access to the response body inside an event hook, you'll263 need to call `response.read()`.263 need to call `response.read()`, or for AsyncClients, `response.aread()`.264265The hooks are also allowed to modify `request` and `response` objects.266267```python
924 unmodified lines