From d83c63429eba755f5971217917e57feee85034be Mon Sep 17 00:00:00 2001 From: "Paul J. Davis" Date: Wed, 27 Apr 2011 13:26:40 -0400 Subject: [PATCH] Empty chunks incorrectly signal end of response. If an app iterator attempts to send an empty string to the client while using chunked transfer encoding it incorrectly signals the end of the transfer. This patch just ignores empty strings that are yielded by the application. --- gunicorn/http/wsgi.py | 5 +++++ 1 file changed, 5 insertions(+) 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)