1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Also skip Content-Encoding and Vary header if 304

This commit is contained in:
Kohei Suzuki 2015-03-12 23:14:01 +09:00
parent d4103fc232
commit b60c1fe97b
2 changed files with 6 additions and 4 deletions

View file

@ -47,10 +47,11 @@ module ActionDispatch
if gzip_path && gzip_encoding_accepted?(env)
env['PATH_INFO'] = gzip_path
status, headers, body = @file_server.call(env)
headers['Content-Encoding'] = 'gzip'
if status != 304
headers['Content-Type'] = content_type(path)
if status == 304
return [status, headers, body]
end
headers['Content-Encoding'] = 'gzip'
headers['Content-Type'] = content_type(path)
else
status, headers, body = @file_server.call(env)
end

View file

@ -149,7 +149,8 @@ module StaticTests
response = get(file_name, 'HTTP_ACCEPT_ENCODING' => 'gzip', 'HTTP_IF_MODIFIED_SINCE' => last_modified.httpdate)
assert_equal 304, response.status
assert_equal nil, response.headers['Content-Type']
assert_equal 'gzip', response.headers['Content-Encoding']
assert_equal nil, response.headers['Content-Encoding']
assert_equal nil, response.headers['Vary']
end
# Windows doesn't allow \ / : * ? " < > | in filenames