about summary refs log tree commit homepage
path: root/test
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-04-12 21:52:48 -0700
committerEric Wong <normalperson@yhbt.net>2009-04-12 21:56:28 -0700
commitac44225fb21e0dbc3a716cec3ea3133a0b2435a0 (patch)
treee476b5db46b2a489b4dce0b64e927a193676c231 /test
parent62ebc930c6e3b46cd200212748800c1ca448eb1f (diff)
downloadunicorn-ac44225fb21e0dbc3a716cec3ea3133a0b2435a0.tar.gz
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.
Diffstat (limited to 'test')
-rw-r--r--test/unit/test_request.rb12
1 files changed, 11 insertions, 1 deletions
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" \