Skip to content

Commit

Permalink
Merge pull request benoitc#1079 from darkrain42/empty-message-for-HEA…
Browse files Browse the repository at this point in the history
…D-replies

Ensure response to HEAD request won't have message body
  • Loading branch information
benoitc committed Jan 22, 2016
2 parents f0d5565 + 8926565 commit 3a5d7b0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions gunicorn/http/wsgi.py
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 3a5d7b0

Please sign in to comment.