HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/lib/python3.10/site-packages/websockets/__pycache__/http11.cpython-310.pyc
o

�hM:�@sVddlmZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZddl
mZddlmZgd	�Zd
jej�Zej�dde�d
e���Zej�dde�d
e���Zeej�dd��Zeej�dd��Zeej�dd��Zd1dd�Ze�d�Ze�d�Z ej!Gdd�d��Z"ej!Gdd �d ��Z#d2d$d%�Z$d3d'd(�Z%d4d/d0�Z&dS)5�)�annotationsN)�	Generator)�Callable�)�Headers)�
SecurityError)�version)�SERVER�
USER_AGENT�Request�Responsez{}.{}�WEBSOCKETS_USER_AGENTzPython/z websockets/�WEBSOCKETS_SERVER�WEBSOCKETS_MAX_NUM_HEADERS�128�WEBSOCKETS_MAX_LINE_LENGTH�8192�WEBSOCKETS_MAX_BODY_SIZE�	1_048_576�value�bytes�return�strcCs|jdd�S)zG
    Decode a bytestring for interpolating into an error message.

    �backslashreplace��errors)�decode)r�r�D/usr/local/CyberCP/lib/python3.10/site-packages/websockets/http11.py�d2srs[-!#$%&\'*+.^_`|~0-9a-zA-Z]+s[\x09\x20-\x7e\x80-\xff]*c@sTeZdZUdZded<ded<dZded<edd
d��Zeddd��Z	ddd�Z
dS)rz�
    WebSocket handshake request.

    Attributes:
        path: Request path, including optional query.
        headers: Request headers.
    r�pathr�headersN�Exception | None�
_exceptionrcC�t�dt�|jS)NzIRequest.exception is deprecated; use ServerProtocol.handshake_exc instead��warnings�warn�DeprecationWarningr#��selfrrr�	exception^s
�zRequest.exception�	read_line�-Callable[[int], Generator[None, None, bytes]]�Generator[None, None, Request]c	
cs��z	t|�EdH}Wnty}ztd�|�d}~wwz|�dd�\}}}Wnty8tdt|����d�w|dkrFtdt|�����|dkrStd	t|�����|�d
d�}t|�EdH}d|vrhtd
��d|vrptd��|||�S)a�
        Parse a WebSocket handshake request.

        This is a generator-based coroutine.

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

        The request path and headers are expected to contain only ASCII
        characters. Other characters are represented with surrogate escapes.

        :meth:`parse` 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 the data stream after :meth:`parse` returns.

        Args:
            read_line: Generator-based coroutine that reads a LF-terminated
                line or raises an exception if there isn't enough data

        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� �zinvalid HTTP request line: �HTTP/1.1�)unsupported protocol; expected HTTP/1.1: sGETz+unsupported HTTP method; expected GET; got �ascii�surrogateescape�Transfer-Encodingz!transfer codings aren't supported�Content-Lengthzunsupported request body)�
parse_line�EOFError�split�
ValueErrorrr�
parse_headers�NotImplementedError)	�clsr,�request_line�exc�method�raw_path�protocolr r!rrr�parsefs2�#
����
z
Request.parsercCs$d|j�d���}||j��7}|S)z;
        Serialize a WebSocket handshake request.

        zGET z HTTP/1.1
)r �encoder!�	serialize)r*�requestrrrrE�szRequest.serialize�rr")r,r-rr.�rr)�__name__�
__module__�__qualname__�__doc__�__annotations__r#�propertyr+�classmethodrCrErrrrrNs
?rc@sleZdZUdZded<ded<ded<dZd	ed
<dZded
<eddd��Ze		dddd��Z
d dd�ZdS)!rz�
    WebSocket handshake response.

    Attributes:
        status_code: Response code.
        reason_phrase: Response reason.
        headers: Response headers.
        body: Response body.

    �int�status_coder�
reason_phraserr!�r�bodyNr"r#rcCr$)NzJResponse.exception is deprecated; use ClientProtocol.handshake_exc insteadr%r)rrrr+�s
�zResponse.exceptionTr,r-�
read_exact�read_to_eof�include_body�bool�Generator[None, None, Response]c
csH�z	t|�EdH}Wnty}ztd�|�d}~wwz|�dd�\}}}	Wnty8tdt|����d�w|dkrFtdt|�����zt|�}
Wnty]tdt|����d�wd	|
krhd
ksrntdt|�����t�|	�s�tdt|	�����|	�d
d�}t	|�EdH}|r�t
|
||||�EdH}
nd}
||
|||
�S)a�
        Parse a WebSocket handshake response.

        This is a generator-based coroutine.

        The reason phrase and headers are expected to contain only ASCII
        characters. Other characters are represented with surrogate escapes.

        Args:
            read_line: Generator-based coroutine that reads a LF-terminated
                line or raises an exception if there isn't enough data.
            read_exact: Generator-based coroutine that reads the requested
                bytes or raises an exception if there isn't enough data.
            read_to_eof: Generator-based coroutine that reads until the end
                of the stream.

        Raises:
            EOFError: If the connection is closed without a full HTTP response.
            SecurityError: If the response exceeds a security limit.
            LookupError: If the response isn't well formatted.
            ValueError: If the response isn't well formatted.

        Nz0connection closed while reading HTTP status liner/r0zinvalid HTTP status line: r1r2z+invalid status code; expected integer; got �diXu-invalid status code; expected 100–599; got zinvalid HTTP reason phrase: r3r4rS)r7r8r9r:rrP�	_value_re�	fullmatchrr;�	read_body)r=r,rUrVrW�status_liner?rB�raw_status_code�
raw_reasonrQ�reasonr!rTrrrrC�sN�!
��������

�zResponse.parsecCs6d|j�d|j�d���}||j��7}||j7}|S)z<
        Serialize a WebSocket handshake response.

        z	HTTP/1.1 � z
)rQrRrDr!rErT)r*�responserrrrEs
zResponse.serializerG)T)
r,r-rUr-rVr-rWrXrrYrH)rIrJrKrLrMrTr#rNr+rOrCrErrrrr�s
�Frr,r-�Generator[None, None, bytes]ccsJ�z	|t�EdH}Wntytd��w|�d�std��|dd�S)ao
    Parse a single line.

    CRLF is stripped from the return value.

    Args:
        read_line: Generator-based coroutine that reads a LF-terminated line
            or raises an exception if there isn't enough data.

    Raises:
        EOFError: If the connection is closed without a CRLF.
        SecurityError: If the response exceeds a security limit.

    Nz
line too long�
zline without CRLF���)�MAX_LINE_LENGTH�RuntimeErrorr�endswithr8)r,�linerrrr7#s��
r7�Generator[None, None, Headers]c	cs��t�}ttd�D]p}z	t|�EdH}Wnty&}ztd�|�d}~ww|dkr.|Sz
|�dd�\}}WntyItdt|����d�wt�	|�sXtdt|�����|�
d�}t�	|�sktd	t|�����|�d
�}|�d
d�}|||<q
t
d��)
a�
    Parse HTTP headers.

    Non-ASCII characters are represented with surrogate escapes.

    Args:
        read_line: Generator-based coroutine that reads a LF-terminated line
            or raises an exception if there isn't enough data.

    Raises:
        EOFError: If the connection is closed without complete headers.
        SecurityError: If the request exceeds a security limit.
        ValueError: If the request isn't well formatted.

    rNz,connection closed while reading HTTP headersrS�:zinvalid HTTP header line: zinvalid HTTP header name: s 	zinvalid HTTP header value: r3r4ztoo many HTTP headers)r�range�MAX_NUM_HEADERSr7r8r9r:r�	_token_rer\�stripr[rr)	r,r!�_rjr?�raw_name�	raw_value�namerrrrr;>s4�
����




r;rQrPr!rrUrVc
cs��d|krdksn|dks|dkrdS|�d�}dur�|dkr+td|�d	���d}	t|�EdH}|�dd�d
}t|�dkrQ|jdd�}	td|	�d���t|d�}
|
d
kr[n,t|�|
tkrptd|
�dt|��d���|||
�EdH7}|d�EdHdkr�t	d��q.t
|�EdH|S|�d�}dur�t|�dkr�td|�d���t|�}|tkr�td|�d���||�EdHSz|t�EdHWSty�tdt�d���w)NrZ����i0rSr5�chunkedztransfer coding z isn't supportedT�;rr�rrzchunk too large: 0xz bytes�zchunk too large: z
 bytes after r0rezchunk without CRLFr6�zbody too large: zbody too large: over )�getr<r7r9�lenrrrP�
MAX_BODY_SIZEr:r;rh)
rQr!r,rUrV�codingrT�chunk_size_line�raw_chunk_size�str_chunk_size�
chunk_size�raw_content_length�content_lengthrrrr]qsL�&
���r])rrrr)r,r-rrd)r,r-rrk)rQrPr!rr,r-rUr-rVr-rrd)'�
__future__r�dataclasses�os�re�sysr&�collections.abcr�typingr�datastructuresr�
exceptionsrr�websockets_version�__all__�format�version_info�PYTHON_VERSION�environr|r
r	rPrnrgr~r�compileror[�	dataclassrrr7r;r]rrrr�<module>sD��



c
p
3