mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
ActionDispatch::SSL should keep original header's behavior
`ActionDispatch::SSL` changes headers to `Hash`. So some headers will be broken if there are some middlewares on ActionDispatch::SSL and if it uses `Rack::Utils::HeaderHash`.
This commit is contained in:
parent
88cd09fa47
commit
bb0186cf55
2 changed files with 12 additions and 1 deletions
|
@ -22,7 +22,7 @@ module ActionDispatch
|
|||
|
||||
if request.ssl?
|
||||
status, headers, body = @app.call(env)
|
||||
headers = hsts_headers.merge(headers)
|
||||
headers.reverse_merge!(hsts_headers)
|
||||
flag_cookies_as_secure!(headers)
|
||||
[status, headers, body]
|
||||
else
|
||||
|
|
|
@ -216,4 +216,15 @@ class SSLTest < ActionDispatch::IntegrationTest
|
|||
assert_equal "https://example.co.uk/path?key=value",
|
||||
response.headers['Location']
|
||||
end
|
||||
|
||||
def test_keeps_original_headers_behavior
|
||||
headers = Rack::Utils::HeaderHash.new(
|
||||
"Content-Type" => "text/html",
|
||||
"Connection" => ["close"]
|
||||
)
|
||||
self.app = ActionDispatch::SSL.new(lambda { |env| [200, headers, ["OK"]] })
|
||||
|
||||
get "https://example.org/"
|
||||
assert_equal "close", response.headers["Connection"]
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue