summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Fellinger <m.fellinger@gmail.com>2013-04-19 21:44:52 +0200
committerBenjamin Fleischer <github@benjaminfleischer.com>2014-07-09 17:07:06 -0500
commitf3a378d8f0205978c0a6257b2836f64ee93e2e43 (patch)
tree95a9940f4d3468dce747b88047a975b34b78f878
parentac590d055c936bb9a618e955a690dc836c625211 (diff)
downloadrack-f3a378d8f0205978c0a6257b2836f64ee93e2e43.tar.gz
correct Request#port for lighttpd2 proxy case
-rw-r--r--lib/rack/request.rb2
-rw-r--r--test/spec_request.rb5
2 files changed, 7 insertions, 0 deletions
diff --git a/lib/rack/request.rb b/lib/rack/request.rb
index e8734d76..6f044195 100644
--- a/lib/rack/request.rb
+++ b/lib/rack/request.rb
@@ -100,6 +100,8 @@ module Rack
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
diff --git a/test/spec_request.rb b/test/spec_request.rb
index 9649c5d2..b98cbd4d 100644
--- a/test/spec_request.rb
+++ b/test/spec_request.rb
@@ -93,6 +93,11 @@ describe Rack::Request do
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