]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Expand docs note for async custom handler responses (#1916)
authorTyler Chamberlain <hexarobi@gmail.com>
Mon, 1 Nov 2021 11:39:18 +0000 (06:39 -0500)
committerGitHub <noreply@github.com>
Mon, 1 Nov 2021 11:39:18 +0000 (11:39 +0000)
* 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

docs/advanced.md

index ea012bd94259d1b26028b16101146c7ef0fcba96..54be4ae0605c1b69aa64cf206c2595e27b4c6e63 100644 (file)
@@ -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.