summary refs log tree commit
diff options
context:
space:
mode:
authorJames Tucker <jftucker@gmail.com>2014-08-03 14:27:00 -0300
committerJames Tucker <jftucker@gmail.com>2014-08-03 14:27:00 -0300
commit885765de90579d424748fb36bd456c8dad6589ae (patch)
tree2ff09ca38b6b35ca1889145e3ae4d18df424a8ae
parent84f2946f9296f1e5da8ffd1c7eb96863731eaef1 (diff)
parentc5ffa933442461deae68efae51a8e2c096afae82 (diff)
downloadrack-885765de90579d424748fb36bd456c8dad6589ae.tar.gz
Merge pull request #669 from alindeman/multiple_x_http_forwarded_proto
request.port supports multiple x-http-forwarded-proto values
-rw-r--r--lib/rack/request.rb2
-rw-r--r--test/spec_request.rb3
2 files changed, 4 insertions, 1 deletions
diff --git a/lib/rack/request.rb b/lib/rack/request.rb
index 4f038384..6e386535 100644
--- a/lib/rack/request.rb
+++ b/lib/rack/request.rb
@@ -97,7 +97,7 @@ module Rack
       elsif @env.has_key?("HTTP_X_FORWARDED_HOST")
         DEFAULT_PORTS[scheme]
       elsif @env.has_key?("HTTP_X_FORWARDED_PROTO")
-        DEFAULT_PORTS[@env['HTTP_X_FORWARDED_PROTO']]
+        DEFAULT_PORTS[@env['HTTP_X_FORWARDED_PROTO'].split(',')[0]]
       else
         @env["SERVER_PORT"].to_i
       end
diff --git a/test/spec_request.rb b/test/spec_request.rb
index c4a7400a..94de6b01 100644
--- a/test/spec_request.rb
+++ b/test/spec_request.rb
@@ -96,7 +96,10 @@ describe Rack::Request do
 
     req = Rack::Request.new \
       Rack::MockRequest.env_for("/", "HTTP_HOST" => "localhost", "HTTP_X_FORWARDED_PROTO" => "https", "SERVER_PORT" => "80")
+    req.port.should.equal 443
 
+    req = Rack::Request.new \
+      Rack::MockRequest.env_for("/", "HTTP_HOST" => "localhost", "HTTP_X_FORWARDED_PROTO" => "https,https", "SERVER_PORT" => "80")
     req.port.should.equal 443
   end