From 9f4cf4181f7ca1c91293615c7e77138a39ffade6 Mon Sep 17 00:00:00 2001 From: Dima Barsky Date: Sat, 27 Jul 2013 00:52:53 +0100 Subject: [PATCH] responses 1xx, 204 and 304 should not force the connection to be closed Only these types of responses are allowed to have empty body fix #581 --- gunicorn/http/wsgi.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gunicorn/http/wsgi.py b/gunicorn/http/wsgi.py index 73cadba1..d017c4b8 100644 --- a/gunicorn/http/wsgi.py +++ b/gunicorn/http/wsgi.py @@ -194,6 +194,9 @@ class Response(object): return True if self.response_length is not None or self.chunked: return False + status = self.status.split()[0] if self.status else '' + if status.startswith('1') or status in ('204', '304'): + return False return True def start_response(self, status, headers, exc_info=None):