Skip to content

Commit 623778c

Browse files
committed
Merge pull request jaswope#4 from waterlink/ekosz/fix/dont-drop-port
[FIX] Don't drop the port of the request
2 parents 88605d0 + 00d432b commit 623778c

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/rack/reverse_proxy.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def proxy(env, source_request, matcher)
8989
if response_headers['location'] && options[:replace_response_host]
9090
response_location = URI(response_headers['location'][0])
9191
response_location.host = source_request.host
92+
response_location.port = source_request.port
9293
response_headers['location'] = response_location.to_s
9394
end
9495

spec/rack/reverse_proxy_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@ def app
149149
# puts last_response.headers.inspect
150150
last_response.headers['location'].should == "http://example.com/bar"
151151
end
152+
153+
it "should keep the port of the location" do
154+
stub_request(:get, "http://example.com/test/stuff").to_return(:headers => {"location" => "http://test.com/bar"})
155+
get 'http://example.com:3000/test/stuff'
156+
last_response.headers['location'].should == "http://example.com:3000/bar"
157+
end
152158
end
153159

154160
describe "with ambiguous routes and all matching" do

0 commit comments

Comments
 (0)