module ActionDispatch::Http::URL

def host_with_port

req.host_with_port # => "example.com:8080"
req = ActionDispatch::Request.new 'HTTP_HOST' => 'example.com:8080'

req.host_with_port # => "example.com"
req = ActionDispatch::Request.new 'HTTP_HOST' => 'example.com:80'

req.host_with_port # => "example.com"
req = ActionDispatch::Request.new 'HTTP_HOST' => 'example.com'

(80 or 443)
"example.com:8080". Port is only included if it is not a default port
Returns a \host:\port string for this request, such as "example.com" or
def host_with_port
  "#{host}#{port_string}"
end