Make ASGITransport streamable
#1028
Unanswered
jonathanslenders
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Right now, httpx's
ASGITransportdoes not operate on a stream, it buffers the whole response internally before proceeding.I noticed there is this related issue on the httpx repo: encode/httpx#3391
But independent from that, I successfully implemented a
StreamingASGITransportwhich does not buffer internally.The API is slightly different: the creation of the transport requires the use of a context manager because a task group is needed for running the ASGI endpoint. The code is below.
Feel free to integrate into httpx2 or to ignore. Leaving it here in case it's useful to somebody. I can create a PR if you'd like (but I won't have time to write docs if that's needed.)
Beta Was this translation helpful? Give feedback.
All reactions