-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
304 response should not include Content-Type header #19271
Conversation
@@ -48,7 +48,10 @@ def call(env) | |||
env['PATH_INFO'] = gzip_path | |||
status, headers, body = @file_server.call(env) | |||
headers['Content-Encoding'] = 'gzip' | |||
headers['Content-Type'] = content_type(path) | |||
if status != 304 | |||
# 304 response should not include Content-Type header. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think the comment is necessary here, as the if
already states that statement .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I removed the trivial comment and force-pushed.
As the response status code is 304, I wonder if we could short-cut this middleware altogether. |
Rack::Lint raises an error saying "Content-Type header found in 304 response, not allowed".
21e6db9
to
d4103fc
Compare
Yeah, I think we should skip most of the work of this middleware if 304 |
@rafaelfranca yes, since Of course it'd be much better if this lived in |
When did this behaviour in either rack or rails change? |
@arthurnn @rafaelfranca @pixeltrix I'm sorry but I couldn't figure out what to do. |
As far as I know, if the status code is 304, you wont need to set any header nor a body in the response. So you could return it early. |
Ah, I get it. I modified to skip Content-Encoding and Vary header. |
5e0d5ae
to
7748b49
Compare
7748b49
to
b60c1fe
Compare
304 response should not include Content-Type header
thanks @eagletmt |
@adrianpike thanks for the confirmation. We took the lesser evil temporarily of just including |
304 response should not include Content-Type header
Rack::Lint raises an error saying "Content-Type header found in 304
response, not allowed".