We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7bdaebf commit d3786ebCopy full SHA for d3786eb
1 file changed
src/hypercorn/app_wrappers.py
@@ -105,12 +105,16 @@ def start_response(
105
106
response_body = self.app(environ, start_response)
107
108
- if not response_started:
109
- raise RuntimeError("WSGI app did not call start_response")
110
-
111
- send({"type": "http.response.start", "status": status_code, "headers": headers})
112
try:
+ first_chunk = True
113
for output in response_body:
+ if first_chunk:
+ if not response_started:
+ raise RuntimeError("WSGI app did not call start_response")
114
+
115
+ send({"type": "http.response.start", "status": status_code, "headers": headers})
116
+ first_chunk = False
117
118
send({"type": "http.response.body", "body": output, "more_body": True})
119
finally:
120
if hasattr(response_body, "close"):
0 commit comments