async def read_request(stream: asyncio.StreamReader) -> Tuple[str, "Headers"]:
    """
    Read an HTTP/1.1 GET request from ``stream``.

    ``stream`` is an :class:`~asyncio.StreamReader`.

    Return ``(path, headers)`` where ``path`` is a :class:`str` and
    ``headers`` is a :class:`Headers` instance.

    ``path`` isn't URL-decoded or validated in any way.

    Non-ASCII characters are represented with surrogate escapes.

    Raise an exception if the request isn't well formatted.

    Don't attempt to read the request body because WebSocket handshake
    requests don't have one. If the request contains a body, it may be
    read from ``stream`` after this coroutine returns.

    """
    # https://tools.ietf.org/html/rfc7230#section-3.1.1

    # Parsing is simple because fixed values are expected for method and
    # version and because path isn't checked. Since WebSocket software tends
    # to implement HTTP/1.1 strictly, there's little need for lenient parsing.

    request_line = await read_line(stream)

    # This may raise "ValueError: not enough values to unpack"
    method, raw_path, version = request_line.split(b" ", 2)

    if method != b"GET":
        raise ValueError("Unsupported HTTP method: %r" % method)
    if version != b"HTTP/1.1":
        raise ValueError("Unsupported HTTP version: %r" % version)
    path = raw_path.decode("ascii", "surrogateescape")

    headers = await read_headers(stream)

    return path, headers
async def read_request ( stream : asyncio . StreamReader ) -> Tuple [ str , "Headers" ] : request_line = await read_line ( stream ) method , raw_path , version = request_line . split ( b" " , 2 ) if method != b"GET" : raise ValueError ( "Unsupported HTTP method: %r" % method ) if version != b"HTTP/1.1" : raise ValueError ( "Unsupported HTTP version: %r" % version ) path = raw_path . decode ( "ascii" , "surrogateescape" ) headers = await read_headers ( stream ) return path , headers
Read an HTTP/1.1 GET request from ``stream``.

    ``stream`` is an :class:`~asyncio.StreamReader`.

    Return ``(path, headers)`` where ``path`` is a :class:`str` and
    ``headers`` is a :class:`Headers` instance.

    ``path`` isn't URL-decoded or validated in any way.

    Non-ASCII characters are represented with surrogate escapes.

    Raise an exception if the request isn't well formatted.

    Don't attempt to read the request body because WebSocket handshake
    requests don't have one. If the request contains a body, it may be
    read from ``stream`` after this coroutine returns.