diff options
author | Arthur Nogueira Neves <github@arthurnn.com> | 2015-03-12 11:40:18 -0400 |
---|---|---|
committer | Arthur Nogueira Neves <github@arthurnn.com> | 2015-03-12 11:40:18 -0400 |
commit | ba7e5530d808e14f0cd135480bb7673bca78d3fe (patch) | |
tree | 304a15196f00198ed360f51d12cd0e7f21e4a4ac /actionpack | |
parent | 2ad6502787b8d2acf2f5971068f0623cf36ed25f (diff) | |
parent | b60c1fe97be3af8baf982aaa4638811a37f7a7e9 (diff) | |
download | rails-ba7e5530d808e14f0cd135480bb7673bca78d3fe.tar.gz rails-ba7e5530d808e14f0cd135480bb7673bca78d3fe.tar.bz2 rails-ba7e5530d808e14f0cd135480bb7673bca78d3fe.zip |
Merge pull request #19271 from eagletmt/304-content-type
304 response should not include Content-Type header
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/static.rb | 3 | ||||
-rw-r--r-- | actionpack/test/dispatch/static_test.rb | 10 |
2 files changed, 13 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/static.rb b/actionpack/lib/action_dispatch/middleware/static.rb index 2e1bd45c3d..fdd1bc4e69 100644 --- a/actionpack/lib/action_dispatch/middleware/static.rb +++ b/actionpack/lib/action_dispatch/middleware/static.rb @@ -47,6 +47,9 @@ module ActionDispatch if gzip_path && gzip_encoding_accepted?(env) env['PATH_INFO'] = gzip_path status, headers, body = @file_server.call(env) + if status == 304 + return [status, headers, body] + end headers['Content-Encoding'] = 'gzip' headers['Content-Type'] = content_type(path) else diff --git a/actionpack/test/dispatch/static_test.rb b/actionpack/test/dispatch/static_test.rb index ebc9d71403..288a2084f6 100644 --- a/actionpack/test/dispatch/static_test.rb +++ b/actionpack/test/dispatch/static_test.rb @@ -143,6 +143,16 @@ module StaticTests assert_equal default_response.headers['Content-Type'], response.headers['Content-Type'] end + def test_serves_gzip_files_with_not_modified + file_name = "/gzip/application-a71b3024f80aea3181c09774ca17e712.js" + last_modified = File.mtime(File.join(@root, "#{file_name}.gz")) + 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 nil, response.headers['Content-Encoding'] + assert_equal nil, response.headers['Vary'] + end + # Windows doesn't allow \ / : * ? " < > | in filenames unless RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ def test_serves_static_file_with_colon |