instance method
port
Ruby on Rails 7.1.6
Since v3.0.20Signature
port()
Returns the port number of this request as an integer.
req = ActionDispatch::Request.new 'HTTP_HOST' => 'example.com' req.port # => 80 req = ActionDispatch::Request.new 'HTTP_HOST' => 'example.com:8080' req.port # => 8080
Source
# File actionpack/lib/action_dispatch/http/url.rb, line 253
def port
@port ||= if raw_host_with_port =~ /:(\d+)$/
$1.to_i
else
standard_port
end
end
Defined in actionpack/lib/action_dispatch/http/url.rb line 253
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionDispatch::Http::URL