diff options
author | Kohei Suzuki <eagletmt@gmail.com> | 2015-03-12 23:14:01 +0900 |
---|---|---|
committer | Kohei Suzuki <eagletmt@gmail.com> | 2015-03-12 23:32:07 +0900 |
commit | b60c1fe97be3af8baf982aaa4638811a37f7a7e9 (patch) | |
tree | 6129a4aaab30e5e20c3e3fdfc261996f9e29ef24 | |
parent | d4103fc232044625c6ba4692b4c9bd8779e97ba5 (diff) | |
download | rails-b60c1fe97be3af8baf982aaa4638811a37f7a7e9.tar.gz rails-b60c1fe97be3af8baf982aaa4638811a37f7a7e9.tar.bz2 rails-b60c1fe97be3af8baf982aaa4638811a37f7a7e9.zip |
Also skip Content-Encoding and Vary header if 304
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/static.rb | 7 | ||||
-rw-r--r-- | actionpack/test/dispatch/static_test.rb | 3 |
2 files changed, 6 insertions, 4 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/static.rb b/actionpack/lib/action_dispatch/middleware/static.rb index f5c2acbfb9..fdd1bc4e69 100644 --- a/actionpack/lib/action_dispatch/middleware/static.rb +++ b/actionpack/lib/action_dispatch/middleware/static.rb @@ -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 diff --git a/actionpack/test/dispatch/static_test.rb b/actionpack/test/dispatch/static_test.rb index 9164cbd3aa..288a2084f6 100644 --- a/actionpack/test/dispatch/static_test.rb +++ b/actionpack/test/dispatch/static_test.rb @@ -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 |