Skip to content

Commit 3051dd3

Browse files
author
Aurelien DEROUINEAU
committed
Added tests for X-Forwarded-Port
1 parent aff66b6 commit 3051dd3

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

spec/rack/reverse_proxy_spec.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,16 @@ def app
9292
).to have_been_made
9393
end
9494

95+
it "sets the X-Forwarded-Port header to the proxying port by default" do
96+
stub_request(:any, "example.com/test/stuff")
97+
get "/test/stuff"
98+
expect(
99+
a_request(:get, "http://example.com/test/stuff").with(
100+
:headers => { "X-Forwarded-Port" => "80" }
101+
)
102+
).to have_been_made
103+
end
104+
95105
it "does not produce headers with a Status key" do
96106
stub_request(:get, "http://example.com/2test").to_return(
97107
:status => 301, :headers => { :status => "301 Moved Permanently" }
@@ -194,6 +204,17 @@ def app
194204
).not_to have_been_made
195205
expect(a_request(:get, "http://example.com/test/stuff")).to have_been_made
196206
end
207+
208+
it "does not set the X-Forwarded-Port header to the proxying port" do
209+
stub_request(:any, "example.com/test/stuff")
210+
get "/test/stuff"
211+
expect(
212+
a_request(:get, "http://example.com/test/stuff").with(
213+
:headers => { "X-Forwarded-Port" => "80" }
214+
)
215+
).not_to have_been_made
216+
expect(a_request(:get, "http://example.com/test/stuff")).to have_been_made
217+
end
197218
end
198219

199220
describe "with timeout configuration" do

0 commit comments

Comments
 (0)