File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -179,7 +179,7 @@ def response_location
179
179
end
180
180
181
181
def need_replace_location?
182
- response_headers [ "Location" ] && options [ :replace_response_host ]
182
+ response_headers [ "Location" ] && options [ :replace_response_host ] && response_location . host
183
183
end
184
184
185
185
def setup_request
Original file line number Diff line number Diff line change @@ -322,7 +322,7 @@ def app
322
322
end
323
323
end
324
324
325
- describe "with preserve response host turned on" do
325
+ describe "with replace response host turned on" do
326
326
def app
327
327
Rack ::ReverseProxy . new ( dummy_app ) do
328
328
reverse_proxy "/test" , "http://example.com/" , :replace_response_host => true
@@ -354,6 +354,14 @@ def app
354
354
get "https://example.com/test/stuff"
355
355
expect ( last_response . headers [ "location" ] ) . to eq ( "https://example.com/bar" )
356
356
end
357
+
358
+ it "doesn't replaces the location response header if it has no host" do
359
+ stub_request ( :get , "http://example.com/test/stuff" ) . to_return (
360
+ :headers => { "location" => "/bar" }
361
+ )
362
+ get "http://example.com/test/stuff"
363
+ expect ( last_response . headers [ "location" ] ) . to eq ( "/bar" )
364
+ end
357
365
end
358
366
359
367
describe "with ambiguous routes and all matching" do
You can’t perform that action at this time.
0 commit comments