Skip to content

Commit 0435860

Browse files
committed
Remove Status key from response_headers as per the Rack protocol
see Rack::Lint, https://github.com/rack/rack/blob/master/lib/rack/lint.rb
1 parent 7f7c7de commit 0435860

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

lib/rack/reverse_proxy.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ def proxy(env, source_request, matcher)
8484
# Let rack set the transfer-encoding header
8585
response_headers = Rack::Utils::HeaderHash.new Proxy.normalize_headers(format_headers(target_response.headers))
8686
response_headers.delete('Transfer-Encoding')
87+
response_headers.delete('Status')
8788

8889
# Replace the location header with the proxy domain
8990
if response_headers['Location'] && options[:replace_response_host]

spec/rack/reverse_proxy_spec.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,23 @@ def app
6262
a_request(:get, 'http://example.com/test/stuff').with(:headers => {'X-Forwarded-Host' => 'example.org'}).should have_been_made
6363
end
6464

65-
it 'should format the headers correctly to avoid duplicates' do
65+
it 'should should not produce headers with a Status key' do
6666
stub_request(:get, 'http://example.com/2test').to_return({:status => 301, :headers => {:status => '301 Moved Permanently'}})
6767

6868
get '/2test'
6969

7070
headers = last_response.headers.to_hash
71-
headers['Status'].should == "301 Moved Permanently"
72-
headers['status'].should be_nil
71+
headers['Status'].should be_nil
72+
end
73+
74+
it 'should format the headers correctly to avoid duplicates' do
75+
stub_request(:get, 'http://example.com/2test').to_return(:headers => {:date => 'Wed, 22 Jul 2015 11:27:21 GMT'})
76+
77+
get '/2test'
78+
79+
headers = last_response.headers.to_hash
80+
headers['Date'].should == 'Wed, 22 Jul 2015 11:27:21 GMT'
81+
headers['date'].should be_nil
7382
end
7483

7584
it 'should format the headers with dashes correctly' do

0 commit comments

Comments
 (0)