From 6dc33b1ca42445272833b3a81fb289a40ffc5fc1 Mon Sep 17 00:00:00 2001 From: Brian Rosner Date: Thu, 7 Apr 2011 23:40:19 -0600 Subject: [PATCH] When the response is a 304 turn off chunked responses as there is a guarantee there is no response body (hence no Content-Length defined) This can cause odd behavior with browsers not being able to parse the response correctly (not sure if this is just a property of empty chunked responses or something else) --- gunicorn/http/wsgi.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gunicorn/http/wsgi.py b/gunicorn/http/wsgi.py index 3cda17be..314e00e9 100644 --- a/gunicorn/http/wsgi.py +++ b/gunicorn/http/wsgi.py @@ -208,6 +208,10 @@ class Response(object): return False elif self.req.version <= (1,0): return False + elif self.status.startswith("304"): + # Do not use chunked responses when the response is guaranteed to + # not have a response body. + return False return True def default_headers(self):