Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion actionpack/lib/action_dispatch/middleware/static.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def find_file(path_info, accept_encoding:)
end

def try_files(filepath, content_type, accept_encoding:)
headers = { "content-type" => content_type }
headers = { Rack::CONTENT_TYPE => content_type }

if compressible? content_type
try_precompressed_files filepath, headers, accept_encoding: accept_encoding
Expand Down
12 changes: 12 additions & 0 deletions actionpack/test/dispatch/static_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,18 @@ def test_does_not_modify_path_info
assert_equal file_name, env["PATH_INFO"]
end

def test_only_set_one_content_type
file_name = "/gzip/foo.zoo"
gzip_env = { "PATH_INFO" => file_name, "HTTP_ACCEPT_ENCODING" => "gzip", "REQUEST_METHOD" => "GET" }
response = @app.call(gzip_env)

env = { "PATH_INFO" => file_name, "REQUEST_METHOD" => "GET" }
default_response = @app.call(env)

assert_equal 1, response[1].slice("Content-Type", "content-type").size
assert_equal 1, default_response[1].slice("Content-Type", "content-type").size
end

def test_serves_gzip_with_proper_content_type_fallback
file_name = "/gzip/foo.zoo"
response = get(file_name, "HTTP_ACCEPT_ENCODING" => "gzip")
Expand Down