Method: ActionDispatch::Http::URL#raw_host_with_port
- Defined in:
- actionpack/lib/action_dispatch/http/url.rb
#raw_host_with_port ⇒ Object
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"
312 313 314 315 316 317 318 |
# File 'actionpack/lib/action_dispatch/http/url.rb', line 312 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 |