module ActionDispatch::Http::URL

def standard_port?

req.standard_port? # => false
req = ActionDispatch::Request.new 'HTTP_HOST' => 'example.com:8080'

req.standard_port? # => true
req = ActionDispatch::Request.new 'HTTP_HOST' => 'example.com:80'

Returns whether this request is using the standard port
def standard_port?
  port == standard_port
end