Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Don't drop the port of the request #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/rack/reverse_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def proxy(env, source_request, matcher)
if response_headers['location'] && options[:replace_response_host]
response_location = URI(response_headers['location'][0])
response_location.host = source_request.host
response_location.port = source_request.port
response_headers['location'] = response_location.to_s
end

Expand Down
6 changes: 6 additions & 0 deletions spec/rack/reverse_proxy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ def app
# puts last_response.headers.inspect
last_response.headers['location'].should == "http://example.com/bar"
end

it "should keep the port of the location" do
stub_request(:get, "http://example.com/test/stuff").to_return(:headers => {"location" => "http://test.com/bar"})
get 'http://example.com:3000/test/stuff'
last_response.headers['location'].should == "http://example.com:3000/bar"
end
end

describe "with ambiguous routes and all matching" do
Expand Down