-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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-Type header should be optional in Response #4612
Comments
I do not agree with that, according to I think that an additional optional Response param can solve that issue. aiohttp.web.Response(status=204, force_empty_content_type=True) |
Could you expand on that, please ? If I well understand the RFC, the Section 7.2.1 Type (you quoted):
If my understanding is correct, it means:
So, if not any body is returned, not any |
This issue has been mentioned on aio-libs. There might be relevant details there: https://aio-libs.discourse.group/t/optional-content-type-header/82/1 |
Write custom Response subclass and fix setter aiohttp/aiohttp/web_response.py Line 254 in fe647a0
|
@alex-eri I don't understand why I should write a custom Response subclass for what should be a default behavior. IMHO we should use response subclass to add extra feature/behavior, not to remove them. I found a nice illustration of the issue in Chrome. Currently, if I return a (not-so) empty 404: async def not_found(request):
return Response(status=404)
# < HTTP/1.1 404 Not Found
# < Content-Type: application/octet-stream
# < Content-Length: 0
# (...) Chrome shows an invalid response (due to the If I remove the |
🐞 Describe the bug
I'm not able to remove the
Content-Type
header inaiohttp.web.Response
. However, according to HTTP RFC, theContent-Type
header is not mandatory. Especially if you don't return content (e.g.204 No Content
)💡 To Reproduce
💡 Expected behavior
Be able, some how, to remove the
Content-Type
header.📋 Logs/tracebacks
Result from
curl
:The text was updated successfully, but these errors were encountered: