class ActionDispatch::Routing::Redirect
:nodoc:
def build_response(req)
def build_response(req) uri = URI.parse(path(req.path_parameters, req)) unless uri.host if relative_path?(uri.path) uri.path = "#{req.script_name}/#{uri.path}" elsif uri.path.empty? uri.path = req.script_name.empty? ? "/" : req.script_name end end uri.scheme ||= req.scheme uri.host ||= req.host uri.port ||= req.port unless req.standard_port? req.commit_flash body = "" headers = { "Location" => uri.to_s, "Content-Type" => "text/html; charset=#{ActionDispatch::Response.default_charset}", "Content-Length" => body.length.to_s } ActionDispatch::Response.new(status, headers, body) end
def call(env)
def call(env) ActiveSupport::Notifications.instrument("redirect.action_dispatch") do |payload| request = Request.new(env) response = build_response(request) payload[:status] = @status payload[:location] = response.headers["Location"] payload[:request] = request response.to_a end end
def escape(params)
def escape(params) params.transform_values { |v| Rack::Utils.escape(v) } end
def escape_fragment(params)
def escape_fragment(params) params.transform_values { |v| Journey::Router::Utils.escape_fragment(v) } end
def escape_path(params)
def escape_path(params) params.transform_values { |v| Journey::Router::Utils.escape_path(v) } end
def initialize(status, block)
def initialize(status, block) @status = status @block = block end
def inspect
def inspect "redirect(#{status})" end
def path(params, request)
def path(params, request) block.call params, request end
def redirect?; true; end
def redirect?; true; end
def relative_path?(path)
def relative_path?(path) path && !path.empty? && !path.start_with?("/") end