From ac44225fb21e0dbc3a716cec3ea3133a0b2435a0 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 12 Apr 2009 21:52:48 -0700 Subject: http11: cleanup+safer rack.url_scheme handling Avoid using strcmp() since it could break badly if Ruby ever stopped null-terminating strings C-style. We're also freezing "http" as a global. Rack does not explicitly permit nor deny this, and Mongrel has always used frozen strings as hash values in other places. --- test/unit/test_request.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/unit/test_request.rb b/test/unit/test_request.rb index 5109c7b..0613326 100644 --- a/test/unit/test_request.rb +++ b/test/unit/test_request.rb @@ -55,7 +55,7 @@ class RequestTest < Test::Unit::TestCase assert_nothing_raised { res = @lint.call(env) } end - def test_x_forwarded_proto + def test_x_forwarded_proto_https res = env = nil client = MockRequest.new("GET / HTTP/1.1\r\n" \ "X-Forwarded-Proto: https\r\n" \ @@ -65,6 +65,16 @@ class RequestTest < Test::Unit::TestCase assert_nothing_raised { res = @lint.call(env) } end + def test_x_forwarded_proto_http + res = env = nil + client = MockRequest.new("GET / HTTP/1.1\r\n" \ + "X-Forwarded-Proto: http\r\n" \ + "Host: foo\r\n\r\n") + assert_nothing_raised { env = @request.read(client) } + assert_equal "http", env['rack.url_scheme'] + assert_nothing_raised { res = @lint.call(env) } + end + def test_x_forwarded_proto_invalid res = env = nil client = MockRequest.new("GET / HTTP/1.1\r\n" \ -- cgit v1.2.3-24-ge0c7