def request_host(request):
    """Return request-host, as defined by RFC 2965.

    Variation from RFC: returned value is lowercased, for convenient
    comparison.

    """
    url = request.get_full_url()
    parse_result = compat.urlparse.urlparse(url)
    scheme, host, port = parse_result.scheme, parse_result.hostname, parse_result.port
    try:
        port = int(port)
    except ValueError:
        pass
    if host == "":
        host = request.get_header("Host", "")

    if port != default_ports.get(scheme):
        host = "%s:%s" % (host, port)
    return host
def request_host ( request ) : url = request . get_full_url ( ) parse_result = compat . urlparse . urlparse ( url ) scheme , host , port = parse_result . scheme , parse_result . hostname , parse_result . port try : port = int ( port ) except ValueError : pass if host == "" : host = request . get_header ( "Host" , "" ) if port != default_ports . get ( scheme ) : host = "%s:%s" % ( host , port ) return host
Return request-host, as defined by RFC 2965.

    Variation from RFC: returned value is lowercased, for convenient
    comparison.