diff options
author | Andy Lindeman <andy@lindeman.io> | 2014-03-24 22:08:15 -0400 |
---|---|---|
committer | Andy Lindeman <andy@lindeman.io> | 2014-03-24 22:08:15 -0400 |
commit | c5ffa933442461deae68efae51a8e2c096afae82 (patch) | |
tree | 1e0e3bded41dba84ac2f0ca9f075089e6513a966 | |
parent | ce4a3959a5be68684c447ce68c626d0cc84f8c1a (diff) | |
download | rack-c5ffa933442461deae68efae51a8e2c096afae82.tar.gz |
request.scheme supports multiple x-http-forwarded-proto values
-rw-r--r-- | lib/rack/request.rb | 2 | ||||
-rw-r--r-- | test/spec_request.rb | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/lib/rack/request.rb b/lib/rack/request.rb index 07627ddb..380a2e7a 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 f5210e57..3c35ca9a 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 |