Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content-Length header is ignored in web.Response constructor #1400

Closed
major12 opened this issue Nov 14, 2016 · 4 comments
Closed

Content-Length header is ignored in web.Response constructor #1400

major12 opened this issue Nov 14, 2016 · 4 comments
Labels
Milestone

Comments

@major12
Copy link

major12 commented Nov 14, 2016

Long story short

Header Content-Length is ignored in web.Response constructor.
It is set to 0 when body parameter is not passed to constructor.

Expected behaviour

Either to get warning like "your header was ignored" or to have it not ignored.

Actual behaviour

Header value is silently updated.

Steps to reproduce

>>> headers = {'Content-Length':555}
>>> r = web.Response(headers=headers)
>>> r.headers
<CIMultiDict('Content-Type': 'application/octet-stream', 'Content-Length': '0')>

Your environment

aiohttp (1.1.3)
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AMD64)] on win32
Win10

@asvetlov
Copy link
Member

What is use case for providing Content-Length without BODY?

@major12
Copy link
Author

major12 commented Nov 15, 2016

Respond to HEAD request.
The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response.

@asvetlov
Copy link
Member

Good point, thank for report.

@asvetlov asvetlov added good first issue Good for newcomers web labels Dec 7, 2016
@asvetlov asvetlov added this to the 1.2 milestone Dec 7, 2016
@lock
Copy link

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

No branches or pull requests

2 participants