Async streaming responses documentation is missing some details #2310
Replies: 5 comments 2 replies
-
|
Interesting, thanks. These bits of info are documented in the Developer Interface docs. Ideally readers would be directed there if they'd like to see what methods are available for async responses, rather than half-duplicating that info in the guide. There's wider discussion on the quality of the API Reference material in the HTTPX documentation here, #1220. |
Beta Was this translation helpful? Give feedback.
-
|
Huh, thanks - I didn't know about https://www.python-httpx.org/api/#response ! I always hit https://www.python-httpx.org/async/ when I'm looking for documentation. Having an obvious link from that section in https://www.python-httpx.org/async/ to https://www.python-httpx.org/api/#response would solve this issue for me. |
Beta Was this translation helpful? Give feedback.
-
|
One thing that might have helped me spot that: I think my eyes skipped straight over "Developer Interface", since I assumed it was aimed at maintainers of the library and not at library users for some reason. If that menu item had been called "API Reference" I think I would have been more likely to have explored it. |
Beta Was this translation helpful? Give feedback.
-
Right, to be fair the exact same happens to me all the time! I proposed #2308 which groups all "Reference material" stuff under a more usual Doesn't change the "Developer Interface" yet. I'm thinking seeing the only other items under that section would be "Exceptions" and "Environment Variables", it might become clear enough that this contains a reference of the public API... |
Beta Was this translation helpful? Give feedback.
-
Yet, there doesn't appear to be any explanation for this difference in the aforementioned docs. Perhaps with content-encoding or transfer-encoding raw returns the compressed content? In any case, this needs to be documented. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
https://www.python-httpx.org/async/#streaming-responses
Current snapshot: https://github.com/encode/httpx/blob/67e9c14952340bfd799a0de41dfaf269f376653d/docs/async.md#streaming-responses
This section in particular:
The missing details I'm talking about include:
await Response.aread()returns abytesobjectResponse.aiter_bytes()returns an async iterator overbytes- and accepts an optionalchunk_size=integerResponse.aiter_text()returns an async iterator overstr- and accepts an optionalchunk_size=integer - it decodes text using the the response's encoding, if set, but then defaults toutf-8Response.aiter_lines()returns an async iterator overstr- but each string is a full line, unlikeaiter_text()Response.aiter_raw()returns an async iterator overbytesand accepts an optionalchunk_size=integer. The difference between this and.aiter_bytes()isn't obvious to meI figured most of this out by looking at the type annotations in this file:
httpx/httpx/_models.py
Line 890 in 67e9c14
Beta Was this translation helpful? Give feedback.
All reactions