Skip to content

Don't send body in response to HEAD request#838

Merged
fafhrd91 merged 2 commits intoaio-libs:masterfrom
lgelo:master
May 23, 2016
Merged

Don't send body in response to HEAD request#838
fafhrd91 merged 2 commits intoaio-libs:masterfrom
lgelo:master

Conversation

@lgelo
Copy link
Copy Markdown
Contributor

@lgelo lgelo commented Mar 21, 2016

What these changes does?

Skips sending Response body when request method is HEAD or status code is 204 or 304. Satisfies requirements of RFC7230 an RFC7231 that server MUST NOT send message body in such responses.

How to test your changes?

Test case is included:
test_head_returns_empty_body (tests/test_web_functional.py)

Related issue number

Problems with HEAD responses #820

Checklist

  • Code is written and well
  • Tests for the changes are provided
  • Documentation reflects the changes

self.body = text.encode(self.charset)

def should_send_body(self):
return (self._req.method.lower() != 'head' and
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to convert to lowercase, please use hdrs.METH_HEAD instead

@popravich popravich added the web label Mar 22, 2016
@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.001%) to 98.265% when pulling a7d5995 on lgelo:master into a1f39a9 on KeepSafe:master.

@fafhrd91 fafhrd91 merged commit 83975df into aio-libs:master May 23, 2016
@fafhrd91
Copy link
Copy Markdown
Member

thanks

@lock
Copy link
Copy Markdown

lock bot commented Oct 29, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants