Skip to content

Commit

Permalink
Merge pull request #669 from alindeman/multiple_x_http_forwarded_proto
Browse files Browse the repository at this point in the history
request.port supports multiple x-http-forwarded-proto values
  • Loading branch information
raggi committed Aug 3, 2014
2 parents 84f2946 + c5ffa93 commit 885765d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rack/request.rb
Expand Up @@ -97,7 +97,7 @@ def port
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
Expand Down
3 changes: 3 additions & 0 deletions test/spec_request.rb
Expand Up @@ -96,7 +96,10 @@

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

Expand Down

0 comments on commit 885765d

Please sign in to comment.