-
Notifications
You must be signed in to change notification settings - Fork 127
Description
When I'm using hypercorn to deploy wsgidav, it raise
RuntimeError("WSGI app did not call start_response")
After inspecting codes from both project, I find out that wsgidav calls start_response when creating the first chunk of response, not when calling the app object. To figure out whose fault is, I check python PEP 3333 – Python Web Server Gateway Interface v1.0.1. It says:
However, the start_response callable must not actually transmit the response headers. Instead, it must store them for the server or gateway to transmit only after the first iteration of the application return value that yields a non-empty bytestring, or upon the application’s first invocation of the write() callable. In other words, response headers must not be sent until there is actual body data available, or until the application’s returned iterable is exhausted. (The only possible exception to this rule is if the response headers explicitly include a Content-Length of zero.)
According to my understanding, hypercorn should do the first iteration of the application before checking whether start_response
is called and sending the headers.
I have created a pull request to demonstrate and fix this issue.