diff options
Diffstat (limited to 'lib/yahns/proxy_pass.rb')
-rw-r--r-- | lib/yahns/proxy_pass.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/yahns/proxy_pass.rb b/lib/yahns/proxy_pass.rb index 15c9f53..89c6ef8 100644 --- a/lib/yahns/proxy_pass.rb +++ b/lib/yahns/proxy_pass.rb @@ -172,7 +172,7 @@ class Yahns::ProxyPass # :nodoc: end end # class ReqRes - def initialize(dest) + def initialize(dest, opts = {}) case dest when %r{\Aunix:([^:]+)(?::(/.*))?\z} path = $2 @@ -184,6 +184,12 @@ class Yahns::ProxyPass # :nodoc: else raise ArgumentError, "destination must be an HTTP URL or unix: path" end + @response_headers = opts[:response_headers] || {} + + # It's wrong to send the backend Server tag through. Let users say + # { "Server => "yahns" } if they want to advertise for us, but don't + # advertise by default (for security) + @response_headers['Server'] ||= :ignore init_path_vars(path) end @@ -237,6 +243,7 @@ class Yahns::ProxyPass # :nodoc: ctype = env["CONTENT_TYPE"] and req << "Content-Type: #{ctype}\r\n" clen = env["CONTENT_LENGTH"] and req << "Content-Length: #{clen}\r\n" input = chunked || (clen && clen.to_i > 0) ? env['rack.input'] : nil + env['yahns.proxy_pass.response_headers'] = @response_headers # finally, prepare to emit the headers rr.req_start(c, req << "\r\n".freeze, input, chunked) |