Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ActionDispatch:SSL: don't include STS header in non-https responses #11065

Merged
merged 1 commit into from Jun 24, 2013
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions actionpack/lib/action_dispatch/middleware/ssl.rb
Expand Up @@ -36,8 +36,7 @@ def redirect_to_https(request)
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
Expand Down
5 changes: 5 additions & 0 deletions actionpack/test/dispatch/ssl_test.rb
Expand Up @@ -37,6 +37,11 @@ def test_hsts_header_by_default
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/"
Expand Down