-
-
Notifications
You must be signed in to change notification settings - Fork 115
Disable Content-Type header on 204 No Content #62
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
Conversation
@stefanoverna Thanks for this PR. I agree, referencing |
There are others http responses which require an empty body, from the rfc (http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html): |
@rugginoso True, I've put that thing in place for I think we should differentiate between "empty headers" policy and "empty body", because some HTTP statuses like 204 want totally empty response. Also, this looks like a control to move away from The reason is simple: we need to check at the end of the pipeline that the body/headers are empty when needed. Would you guys mind to amend this PR with those changes and rebase? Thank you! |
@jodosha yeah, sure. Will try to do it! 👍 |
@jodosha how about something like this? |
@stefanoverna I'm sorry for the late reply here. RFC 2616
The server has fulfilled the request but does not need to return an In my understanding, HTTP headers can be sent if they are related to entities (aka custom headers). At the same time, default headers like Because this isn't mime type related issue, we should extract that test into a separated case under diff --git a/test/integration/mime_type_test.rb b/test/integration/mime_type_test.rb
index bd7fe18..c339332 100644
--- a/test/integration/mime_type_test.rb
+++ b/test/integration/mime_type_test.rb
@@ -78,6 +78,8 @@ module Mimes
def call(params)
self.status = 204
+ headers['Content-Length'] = '0'
+ headers['X-Entity'] = 'OK'
end
end
end
@@ -114,7 +116,9 @@ describe 'Content type' do
it 'does not produce a "Content-Type" header when the request has a 204 No Content status' do
response = @app.get('/nocontent')
response.headers['Content-Type'].must_be_nil
- response.body.must_equal ''
+ response.headers['Content-Length'].must_be_nil
+ response.headers['X-Entity'].must_equal 'OK'
+ response.body.must_equal ''
end Would you like to take care of this? Thank you! |
@jodosha I'm not entirely sold on your interpretation.. entity-headers are not custom headers (ie.
So, it seems that passing ie. |
@stefanoverna @rugginoso There was some Git conflicts now solved. I also cleaned up the code and added new tests. I'm going to merge this to ease the workflow, but there are still some unresolved points that I would love to discuss in another GH issue. Thanks for your effort until now! 👍 |
great @jodosha feel free to mention us :) |
@stefanoverna @rugginoso @lotus/core-team I moved the discussion here: rack/rack#787 |
👍 |
As Rack::Lint points out, if the response status is 204, there should not be any Content-Type header set. Let me know if everything is alright with this PR @jodosha. I don't really like having to reference
@_status
outside of Lotus::Action::Rack, but there's no getter :confused: