File: //usr/local/CyberCP/lib/python3.10/site-packages/websockets/legacy/__pycache__/http.cpython-310.pyc
o
�h� � @ s� d dl mZ d dlZd dlZd dlZddlmZ ddlmZ ddgZ e
ej�dd ��Z
e
ej�d
d��Zddd�Ze�d�Ze�d�Zd dd�Zd!dd�Zd"dd�Zd#dd�ZdS )$� )�annotationsN� )�Headers)�
SecurityError�read_request�
read_response�WEBSOCKETS_MAX_NUM_HEADERS�128�WEBSOCKETS_MAX_LINE_LENGTH�8192�value�bytes�return�strc C s | j dd�S )zG
Decode a bytestring for interpolating into an error message.
�backslashreplace)�errors)�decode)r � r �I/usr/local/CyberCP/lib/python3.10/site-packages/websockets/legacy/http.py�d s r s [-!#$%&\'*+.^_`|~0-9a-zA-Z]+s [\x09\x20-\x7e\x80-\xff]*�stream�asyncio.StreamReader�tuple[str, Headers]c
� s� �z t | �I dH }W n ty } ztd�|�d}~ww z|�dd�\}}}W n ty8 tdt|�� ��d�w |dkrFtdt|�� ���|dkrStd t|�� ���|�d
d�}t| �I dH }||fS )a�
Read an HTTP/1.1 GET request and return ``(path, headers)``.
``path`` isn't URL-decoded or validated in any way.
``path`` and ``headers`` are expected to contain only ASCII characters.
Other characters are represented with surrogate escapes.
:func:`read_request` doesn'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.
Args:
stream: Input to read the request from.
Raises:
EOFError: If the connection is closed without a full HTTP request.
SecurityError: If the request exceeds a security limit.
ValueError: If the request isn't well formatted.
Nz1connection closed while reading HTTP request line� r zinvalid HTTP request line: s GETzunsupported HTTP method: � HTTP/1.1�unsupported HTTP version: �ascii�surrogateescape)� read_line�EOFError�split�
ValueErrorr r �read_headers)r �request_line�exc�method�raw_path�version�path�headersr r r r - s&