aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2016-02-24 11:26:49 +1030
committerMatthew Draper <matthew@trebex.net>2016-02-24 11:26:49 +1030
commit52bcbde60d101536d531337b9edb83a94604bc74 (patch)
tree4b5b82039ba96581e872d035df295c4b2ee54016
parent2c02bc0a47777ad8cf98e1465c08b1a68151803e (diff)
parent6edfcdd4aa896dbbf431fcf3992e0d1cd2dac3b2 (diff)
downloadrails-52bcbde60d101536d531337b9edb83a94604bc74.tar.gz
rails-52bcbde60d101536d531337b9edb83a94604bc74.tar.bz2
rails-52bcbde60d101536d531337b9edb83a94604bc74.zip
Merge pull request #23632 from maclover7/fix-23620
Fix `request.ssl?` bug with Action Cable
-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