WSGI transport does not close the iterable returned by the application #1822
-
The WSGI spec requires the gateway (httpx in this case) to call
httpx currently does not do this when wrapping a WSGI app. This can be verified with the import httpx
from wsgiref.validate import validator
def application(environ, start_response):
start_response("200 OK", [("content-type", "text/plain")])
return [b"hello, world"]
application = validator(application)
with httpx.Client(app=application, base_url="http://localhost") as client:
response = client.get("/") Expected output: nothing Actual output:
I'm often using httpx to test WSGI apps (great feature btw!), and it would be good if I can submit a PR if you agree this is an issue. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
What a very neatly summarised discussion - thank you! 😁 Yes that sounds valid. I think the place to deal with this will be adding a |
Beta Was this translation helpful? Give feedback.
What a very neatly summarised discussion - thank you! 😁
Yes that sounds valid. I think the place to deal with this will be adding a
close()
method to theWSGIByteStream
class.That'll get called into when the response is closed.