-
-
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
Response sends content-type when no body is sent #1191
Comments
What behavior it breaks? |
We have a unit test that checked there was no content type being sent on our API's 404 response, which has no body. I don't know if it actually breaks anything, it's just not quite in line with the RFCs. |
Sorry, I couldn't find exact RFC rule for this. |
The default references RFC 2616. I've down broken the paragraph I think it's referencing below:
If there is an entity-body sending a Content-Type header is advised, but optional.
If missing, clients are permitted to guess.
If clients can't guess, fall back to "application/octet-stream" I don't think this suggests that an HTTP server should by default send a header with a default value. |
Well, the rule for not sending
The problem is: on headers sending stage it's impossible to figure out will user send data later or not? The change was introduced by #1124 (fix for #944) and 3d53ba8 I don't think that server's behavior is incorrect now. It shouldn't break any existing client I believe. |
Hmm. Okay so is there a easy way to tell aiohttp to not send a content-type? The reason we do this is our 404 response has no body but used to send a content-type heaser; Firefox would try to parse the empty body and would complain that the json was malformed. |
|
BTW default Content-Type is |
It used to, when I originally fixed that I added the test to assert there was no header, which led to this issue when we upgraded! Anyway, if it's simple to work around, and won't break anything then I'm happy to close this. On 23 September 2016 14:21:56 BST, Andrew Svetlov notifications@github.com wrote:
Sent from my phone. Please excuse my brevity. |
Sure! |
Long story short
With a recent release the "default" content type became "application/octet-stream".
This appears to be added to responses which do not include a body, so content-type is not relevant.
Expected behaviour
No content-type header present
Actual behaviour
content-type: "application/octet-stream"
Steps to reproduce
Your environment
The text was updated successfully, but these errors were encountered: