Merge pull request #567 from kjkuan/fix-chunked-encoding-with-empty-body
Fix the problem with chunked encoding with an empty body.
This commit is contained in:
+5
-4
@@ -1850,13 +1850,14 @@ class WSGIWorker(Worker):
|
|||||||
if data:
|
if data:
|
||||||
self.write(data, sections)
|
self.write(data, sections)
|
||||||
|
|
||||||
if self.chunked:
|
if not self.headers_sent:
|
||||||
# If chunked, send our final chunk length
|
|
||||||
self.conn.sendall(b('0\r\n\r\n'))
|
|
||||||
elif not self.headers_sent:
|
|
||||||
# Send headers if the body was empty
|
# Send headers if the body was empty
|
||||||
self.send_headers('', sections)
|
self.send_headers('', sections)
|
||||||
|
|
||||||
|
if self.chunked and self.request_method != 'HEAD':
|
||||||
|
# If chunked, send our final chunk length
|
||||||
|
self.conn.sendall(b('0\r\n\r\n'))
|
||||||
|
|
||||||
# Don't capture exceptions here. The Worker class handles
|
# Don't capture exceptions here. The Worker class handles
|
||||||
# them appropriately.
|
# them appropriately.
|
||||||
finally:
|
finally:
|
||||||
|
|||||||
Reference in New Issue
Block a user