-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
add Content-Type header to the 405 response #343
Conversation
Should this be a |
We actually thought about that but there is no content in the 405 response, so it doesn't makes sense to set a Content-Type. Setting it to Blank prevents Rack throwing the error plus it doesn't get included in the actual response header. |
I read everything I could about this and I don't think an empty content-type is RFC-compatible. I am sure Rack::Lint has a good reason to raise an error though, so we should try to figure this out. I asked SO What should the content-type be for a 4xx error without a body? |
yes, an empty Content-Type in the header is definitely not RFC compliant. But setting the Content-Type as an empty string in the code causes Rack to exclude it from the header entirely, which is RFC compliant. This may be a bit of a hack, since the problem is really with Rack::Lint. Rack::Lint should only require Content-Type if there is actually content. Maybe we should submit a patch to Rack::Lint. |
This has been discussed before in the Rack issues but their solution doesn't seemed to actually fix this issue. (from Rack issues). |
I think I would accept a Content-Type |
agreed, lets see if the guys from rack have a comment. |
I am ready to merge this. Should we do the same for |
Merged in 27d15e2. |
I don't think it would be necessary for the 204 since Rack doesn't enforce that validation for that type of response, and because it means "No Content" don't think it will be changing in the near future. |
Rack throws Rack::Lint::LintError after calling an undefined method for an endpoint, it expects a Content-Type in the response.
Expected response for a PUT request to a defined endpoint that doesn't allow PUT:
Current response:
Stack trace