Skip to content

Commit 152b6c9

Browse files
committed
Prefer lowercase headers in ActionDispatch::Static.
`ActionDispatch::Static` uses mixed-case headers and merges them with lower case headers. This produces duplicate headers. Prefer lowercase headers to avoid this situation.
1 parent ee6a7ba commit 152b6c9

File tree

1 file changed

+5
-5
lines changed
  • actionpack/lib/action_dispatch/middleware

1 file changed

+5
-5
lines changed

actionpack/lib/action_dispatch/middleware/static.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def call(env)
3131
#
3232
# Precompressed versions of these files are checked first. Brotli (.br)
3333
# and gzip (.gz) files are supported. If +path+.br exists, this
34-
# endpoint returns that file with a <tt>Content-Encoding: br</tt> header.
34+
# endpoint returns that file with a <tt>content-encoding: br</tt> header.
3535
#
3636
# If no matching file is found, this endpoint responds <tt>404 Not Found</tt>.
3737
#
@@ -76,7 +76,7 @@ def serve(request, filepath, content_headers)
7676
request.path_info, ::Rack::Utils.escape_path(filepath).b
7777

7878
@file_server.call(request.env).tap do |status, headers, body|
79-
# Omit Content-Encoding/Type/etc headers for 304 Not Modified
79+
# Omit content-encoding/type/etc headers for 304 Not Modified
8080
if status != 304
8181
headers.update(content_headers)
8282
end
@@ -104,7 +104,7 @@ def find_file(path_info, accept_encoding:)
104104
end
105105

106106
def try_files(filepath, content_type, accept_encoding:)
107-
headers = { "Content-Type" => content_type }
107+
headers = { "content-type" => content_type }
108108

109109
if compressible? content_type
110110
try_precompressed_files filepath, headers, accept_encoding: accept_encoding
@@ -124,10 +124,10 @@ def try_precompressed_files(filepath, headers, accept_encoding:)
124124
if content_encoding == "identity"
125125
return precompressed_filepath, headers
126126
else
127-
headers["Vary"] = "Accept-Encoding"
127+
headers["vary"] = "accept-encoding"
128128

129129
if accept_encoding.any? { |enc, _| /\b#{content_encoding}\b/i.match?(enc) }
130-
headers["Content-Encoding"] = content_encoding
130+
headers["content-encoding"] = content_encoding
131131
return precompressed_filepath, headers
132132
end
133133
end

0 commit comments

Comments
 (0)