Skip to content
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

Merged
merged 2 commits into from
Mar 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions actionpack/lib/action_dispatch/middleware/static.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ def call(env)
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
Expand Down
10 changes: 10 additions & 0 deletions actionpack/test/dispatch/static_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,16 @@ def test_serves_gzip_with_propper_content_type_fallback
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
Expand Down