code: def reconstruct_hostname(self, port_override=None):
      
      url = self.server
      port = port_override or self.port
      if port and ((self.url_scheme == 'https' and str(port) != '443') or
                   (self.url_scheme != 'https' and str(port) != '80')):
        url += ':{0}'.format(port)
  
      return url
docs: Reconstruct the hostname of a request.
  
      This is based on the URL reconstruction code in Python PEP 333:
      http://www.python.org/dev/peps/pep-0333/#url-reconstruction.  Rebuild the
      hostname from the pieces available in the environment.
  
      Args:
        port_override: str, An override for the port on the returned hostname.
  
      Returns:
        The hostname portion of the URL from the request, not including the
        URL scheme.