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
This commit is contained in:
Dima Barsky 2013-07-27 00:52:53 +01:00 committed by benoitc
parent fa9d028d09
commit 9f4cf4181f

View File

@ -194,6 +194,9 @@ class Response(object):
return True return True
if self.response_length is not None or self.chunked: if self.response_length is not None or self.chunked:
return False return False
status = self.status.split()[0] if self.status else ''
if status.startswith('1') or status in ('204', '304'):
return False
return True return True
def start_response(self, status, headers, exc_info=None): def start_response(self, status, headers, exc_info=None):