class Rack::Reproxy::Rack
Rack
dispatches the request again and returns the proxied response with its headers merged onto the original response’s.
Public Class Methods
new(app, options = {})
click to toggle source
Calls superclass method
Rack::Reproxy::Middleware::new
# File lib/rack/reproxy.rb, line 148 def initialize(app, options = {}) super @proxy_to = options.fetch(:app, self) end
Private Instance Methods
reproxy(env, status, headers, body)
click to toggle source
# File lib/rack/reproxy.rb, line 154 def reproxy(env, status, headers, body) uri = URI(headers.delete(@header)) path_info = uri.path if script_name = env['SCRIPT_NAME'] path_info.sub! /\A#{Regexp.escape(script_name)}/, '' end proxy_env = env.merge 'HTTP_X_REPROXIED' => '1', 'HTTP_HOST' => uri.host, 'PATH_INFO' => path_info, 'QUERY_STRING' => uri.query proxied_status, proxied_headers, proxied_body = @proxy_to.call(proxy_env) [proxied_status, headers.merge(proxied_headers), proxied_body] end