Permalink
Browse files

correct Request#port for lighttpd2 proxy case

  • Loading branch information...
1 parent a04035d commit da7efac44c7c463fb39e82d40c4a23403db383de @manveru manveru committed Apr 19, 2013
Showing with 7 additions and 0 deletions.
  1. +2 −0 lib/rack/request.rb
  2. +5 −0 test/spec_request.rb
View
@@ -100,6 +100,8 @@ def port
port.to_i
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']]
else
@env["SERVER_PORT"].to_i
end
View
@@ -93,6 +93,11 @@
req = Rack::Request.new \
Rack::MockRequest.env_for("/", "HTTP_HOST" => "localhost:81", "HTTP_X_FORWARDED_HOST" => "example.org", "SERVER_PORT" => "9393")
req.port.should.equal 80
+
+ req = Rack::Request.new \
+ Rack::MockRequest.env_for("/", "HTTP_HOST" => "localhost", "HTTP_X_FORWARDED_PROTO" => "https", "SERVER_PORT" => "80")
+
+ req.port.should.equal 443
end
should "figure out the correct host with port" do

0 comments on commit da7efac

Please sign in to comment.