diff --git a/gunicorn/http/wsgi.py b/gunicorn/http/wsgi.py index 2d31ef0089..1e373bbcd2 100644 --- a/gunicorn/http/wsgi.py +++ b/gunicorn/http/wsgi.py @@ -230,6 +230,8 @@ def should_close(self): return True if self.response_length is not None or self.chunked: return False + if self.req.method == 'HEAD': + return False if self.status_code < 200 or self.status_code in (204, 304): return False return True @@ -287,6 +289,9 @@ def is_chunked(self): return False elif self.req.version <= (1, 0): return False + elif self.req.method == 'HEAD': + # Responses to a HEAD request MUST NOT contain a response body. + return False elif self.status_code in (204, 304): # Do not use chunked responses when the response is guaranteed to # not have a response body.