mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
ActionDispatch:SSL: don't include STS header in non-https responses
This commit is contained in:
parent
11ac1e8a2c
commit
d8bf1f22de
2 changed files with 6 additions and 2 deletions
|
@ -36,8 +36,7 @@ module ActionDispatch
|
|||
url.scheme = "https"
|
||||
url.host = @host if @host
|
||||
url.port = @port if @port
|
||||
headers = hsts_headers.merge('Content-Type' => 'text/html',
|
||||
'Location' => url.to_s)
|
||||
headers = { 'Content-Type' => 'text/html', 'Location' => url.to_s }
|
||||
|
||||
[301, headers, []]
|
||||
end
|
||||
|
|
|
@ -37,6 +37,11 @@ class SSLTest < ActionDispatch::IntegrationTest
|
|||
response.headers['Strict-Transport-Security']
|
||||
end
|
||||
|
||||
def test_no_hsts_with_insecure_connection
|
||||
get "http://example.org/"
|
||||
assert_not response.headers['Strict-Transport-Security']
|
||||
end
|
||||
|
||||
def test_hsts_header
|
||||
self.app = ActionDispatch::SSL.new(default_app, :hsts => true)
|
||||
get "https://example.org/"
|
||||
|
|
Loading…
Reference in a new issue