Skip to content

Commit 82c52b9

Browse files
committed
Refactored header cleaning into separate function
1 parent b59a1bb commit 82c52b9

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/rack/reverse_proxy.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ def call(env)
4545
body << segment
4646
end
4747
end
48-
h = res.to_hash.reject { |k,v| k.downcase == 'status' }
49-
[res.code, Rack::Utils::HeaderHash.new(h), [body]]
48+
49+
[res.code, create_response_headers(res), [body]]
5050
}
5151
end
5252

@@ -66,6 +66,14 @@ def get_matcher_and_url path
6666
end
6767
end
6868

69+
def create_response_headers http_response
70+
response_headers = Rack::Utils::HeaderHash.new(http_response.to_hash)
71+
# handled by Rack
72+
response_headers.delete('status')
73+
# TODO: Verify Content Length, and required Rack headers
74+
response_headers
75+
end
76+
6977
def match_path(path, matcher)
7078
if matcher.is_a?(Regexp)
7179
path.match(matcher)

0 commit comments

Comments
 (0)