aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Moss <me@jonathanmoss.me>2016-02-11 19:41:27 -0500
committerJon Moss <me@jonathanmoss.me>2016-02-23 16:09:44 -0500
commit6edfcdd4aa896dbbf431fcf3992e0d1cd2dac3b2 (patch)
tree1322bbc98894448517f8b183fd0590cdbd123b28
parente9b96f0d666adfd3484641a4a55feb1c774d3378 (diff)
downloadrails-6edfcdd4aa896dbbf431fcf3992e0d1cd2dac3b2.tar.gz
rails-6edfcdd4aa896dbbf431fcf3992e0d1cd2dac3b2.tar.bz2
rails-6edfcdd4aa896dbbf431fcf3992e0d1cd2dac3b2.zip
Fix `request.ssl?` bug with Action Cable
This bug affects `wss://` requests when running Action Cable in-app. Fixes #23620.
-rw-r--r--actionpack/lib/action_dispatch/http/request.rb4
-rw-r--r--actionpack/test/controller/force_ssl_test.rb9
2 files changed, 13 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb
index 5427425ef7..316a9f08b7 100644
--- a/actionpack/lib/action_dispatch/http/request.rb
+++ b/actionpack/lib/action_dispatch/http/request.rb
@@ -403,6 +403,10 @@ module ActionDispatch
def commit_flash
end
+ def ssl?
+ super || scheme == 'wss'.freeze
+ end
+
private
def check_method(name)
HTTP_METHOD_LOOKUP[name] || raise(ActionController::UnknownHttpMethod, "#{name}, accepted HTTP methods are #{HTTP_METHODS[0...-1].join(', ')}, and #{HTTP_METHODS[-1]}")
diff --git a/actionpack/test/controller/force_ssl_test.rb b/actionpack/test/controller/force_ssl_test.rb
index 22f1cc7c22..03a9c9ae78 100644
--- a/actionpack/test/controller/force_ssl_test.rb
+++ b/actionpack/test/controller/force_ssl_test.rb
@@ -322,3 +322,12 @@ class RedirectToSSLTest < ActionController::TestCase
assert_equal 'ihaz', response.body
end
end
+
+class ForceSSLControllerLevelTest < ActionController::TestCase
+ def test_no_redirect_websocket_ssl_request
+ request.env['rack.url_scheme'] = 'wss'
+ request.env['Upgrade'] = 'websocket'
+ get :cheeseburger
+ assert_response 200
+ end
+end