diff --git a/gunicorn/http/wsgi.py b/gunicorn/http/wsgi.py index 4a3907a8..1574a629 100644 --- a/gunicorn/http/wsgi.py +++ b/gunicorn/http/wsgi.py @@ -244,6 +244,11 @@ class Response(object): if tosend < arglen: arg = arg[:tosend] + # Sending an empty chunk signals the end of the + # response and prematurely closes the response + if self.chunked and tosend == 0: + return + self.sent += tosend util.write(self.sock, arg, self.chunked)