instance method
raw_host_with_port
Ruby on Rails 7.2.3
Since v3.0.20Signature
raw_host_with_port()
Returns the host and port for this request, such as “example.com:8080”.
req = ActionDispatch::Request.new 'HTTP_HOST' => 'example.com' req.raw_host_with_port # => "example.com" req = ActionDispatch::Request.new 'HTTP_HOST' => 'example.com:80' req.raw_host_with_port # => "example.com:80" req = ActionDispatch::Request.new 'HTTP_HOST' => 'example.com:8080' req.raw_host_with_port # => "example.com:8080"
Source
# File actionpack/lib/action_dispatch/http/url.rb, line 216
def raw_host_with_port
if forwarded = x_forwarded_host.presence
forwarded.split(/,\s?/).last
else
get_header("HTTP_HOST") || "#{server_name}:#{get_header('SERVER_PORT')}"
end
end
Defined in actionpack/lib/action_dispatch/http/url.rb line 216
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionDispatch::Http::URL