method
build_response
v7.2.3 -
Show latest stable
- Class:
ActionDispatch::Routing::Redirect
build_response(req)public
No documentation available.
# File actionpack/lib/action_dispatch/routing/redirection.rb, line 35
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