def METHOD_NAME(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 = urllib.parse.urlparse(url)
    scheme, host, port = parse_result.scheme, parse_result.hostname, parse_result.port
    try:
        port = int(port)
    except (ValueError, TypeError):
        pass
    if host == "":
        host = request.get_header("Host", "")
    if port and port != default_ports.get(scheme):
        host = "%s:%s" % (host, port)
    return host