Fix the problem with chunked encoding with an empty body.
When the response body is empty, rocket won't send the final zero-length terminating chunk for chunked encoding. I think this causes the browser to wait for the connection close in order to tell the end of the response.
This commit is contained in:
+4
-3
@@ -1850,12 +1850,13 @@ class WSGIWorker(Worker):
|
|||||||
if data:
|
if data:
|
||||||
self.write(data, sections)
|
self.write(data, sections)
|
||||||
|
|
||||||
|
if not self.headers_sent:
|
||||||
|
# Send headers if the body was empty
|
||||||
|
self.send_headers('', sections)
|
||||||
|
|
||||||
if self.chunked:
|
if self.chunked:
|
||||||
# If chunked, send our final chunk length
|
# If chunked, send our final chunk length
|
||||||
self.conn.sendall(b('0\r\n\r\n'))
|
self.conn.sendall(b('0\r\n\r\n'))
|
||||||
elif not self.headers_sent:
|
|
||||||
# Send headers if the body was empty
|
|
||||||
self.send_headers('', sections)
|
|
||||||
|
|
||||||
# Don't capture exceptions here. The Worker class handles
|
# Don't capture exceptions here. The Worker class handles
|
||||||
# them appropriately.
|
# them appropriately.
|
||||||
|
|||||||
Reference in New Issue
Block a user