aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorFumiaki MATSUSHIMA <mtsmfm@gmail.com>2015-06-14 23:10:27 +0900
committerFumiaki MATSUSHIMA <mtsmfm@gmail.com>2015-06-14 23:20:04 +0900
commitbb0186cf5542bca1891e507774447588846f88d1 (patch)
treef77e298eec7038864e99bbe04f036dfb5d716bbb /actionpack
parent88cd09fa47ddf9ea952b2c4d117d725b0d537bae (diff)
downloadrails-bb0186cf5542bca1891e507774447588846f88d1.tar.gz
rails-bb0186cf5542bca1891e507774447588846f88d1.tar.bz2
rails-bb0186cf5542bca1891e507774447588846f88d1.zip
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`.
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_dispatch/middleware/ssl.rb2
-rw-r--r--actionpack/test/dispatch/ssl_test.rb11
2 files changed, 12 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/ssl.rb b/actionpack/lib/action_dispatch/middleware/ssl.rb
index 0c7caef25d..7b3d8bcc5b 100644
--- a/actionpack/lib/action_dispatch/middleware/ssl.rb
+++ b/actionpack/lib/action_dispatch/middleware/ssl.rb
@@ -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
diff --git a/actionpack/test/dispatch/ssl_test.rb b/actionpack/test/dispatch/ssl_test.rb
index 7ced41bc2e..017e9ba2dd 100644
--- a/actionpack/test/dispatch/ssl_test.rb
+++ b/actionpack/test/dispatch/ssl_test.rb
@@ -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