
    g                    B   d dl mZ d dlZd dlZd dlZddlmZ ddlmZ ddgZ	 e
ej                            dd	                    Z e
ej                            d
d                    ZddZ ej        d          Z ej        d          ZddZddZddZd dZdS )!    )annotationsN   )Headers)SecurityErrorread_requestread_responseWEBSOCKETS_MAX_NUM_HEADERS128WEBSOCKETS_MAX_LINE_LENGTH8192valuebytesreturnstrc                .    |                      d          S )zG
    Decode a bytestring for interpolating into an error message.

    backslashreplace)errors)decode)r   s    b/var/www/html/nodeJS/PythonScripts/venv3.11/lib/python3.11/site-packages/websockets/legacy/http.pydr      s    
 <<1<222    s   [-!#$%&\'*+.^_`|~0-9a-zA-Z]+s   [\x09\x20-\x7e\x80-\xff]*streamasyncio.StreamReadertuple[str, Headers]c                  K   	 t          |            d{V }n"# t          $ r}t          d          |d}~ww xY w	 |                    dd          \  }}}n.# t          $ r! t          dt	          |                     dw xY w|dk    rt          dt	          |                     |dk    rt          d	t	          |                     |                    d
d          }t          |            d{V }||fS )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   zinvalid HTTP request line: s   GETzunsupported 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headerss           r   r   r   -   sS     8U&v........ U U UJKKQTTUT$0$6$6tQ$?$?!'' T T THqHHIItST @QvYY@@AAA+BajjBBCCC??7$566D ((((((((G=s    
949A +Btuple[int, str, Headers]c                  K   	 t          |            d{V }n"# t          $ r}t          d          |d}~ww xY w	 |                    dd          \  }}}n.# t          $ r! t          dt	          |                     dw xY w|dk    rt          dt	          |                     	 t          |          }n.# t          $ r! t          dt	          |                     dw xY wd	|cxk    rd
k     s!n t          dt	          |                     t                              |          st          dt	          |                     |                                }t          |            d{V }|||fS )a  
    Read an HTTP/1.1 response and return ``(status_code, reason, headers)``.

    ``reason`` 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 response body because
    WebSocket handshake responses don't have one. If the response contains a
    body, it may be read from ``stream`` after this coroutine returns.

    Args:
        stream: Input to read the response from.

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

    Nz0connection closed while reading HTTP status liner   r   zinvalid HTTP status line: r   r   zinvalid HTTP status code: d   i  zunsupported HTTP status code: zinvalid HTTP reason phrase: )
r!   r"   r#   r$   r   int	_value_re	fullmatchr   r%   )	r   status_liner'   r*   raw_status_code
raw_reasonstatus_codereasonr,   s	            r   r   r   ^   s     2T%f-------- T T TIJJPSSTR/:/@/@q/I/I,** R R RFannFFGGTQR +BajjBBCCCV/** V V VJa6H6HJJKKQUUV+$$$$$$$$N!O:L:LNNOOOz** IG*GGHHH  F ((((((((G''s'    
949A +B,B< <+C'r   c                   K   t                      }t          t          dz             D ]E}	 t          |            d{V }n"# t          $ r}t	          d          |d}~ww xY w|dk    r n	 |                    dd          \  }}n.# t          $ r! t          dt          |                     dw xY wt          	                    |          st          dt          |                     |
                    d          }t          	                    |          st          d	t          |                     |                    d
          }|                    d
d          }|||<   Gt          d          |S )zo
    Read HTTP headers from ``stream``.

    Non-ASCII characters are represented with surrogate escapes.

       Nz,connection closed while reading HTTP headersr      :zinvalid HTTP header line: zinvalid HTTP header name: s    	zinvalid HTTP header value: r   r    ztoo many HTTP headers)r   rangeMAX_NUM_HEADERSr!   r"   r#   r$   r   	_token_rer2   stripr1   r   r   )	r   r,   _liner'   raw_name	raw_valuenamer   s	            r   r%   r%      s      iiG?Q&'' 5 5	T"6********DD 	T 	T 	TIJJPSS	T3;;E	O"&**T1"5"5Hii 	O 	O 	OC!D''CCDD$N	O""8,, 	IG!H++GGHHHOOF++	""9-- 	KI1Y<<IIJJJw''  *;<< 3444Ns#   A
A!AA!.B+B3c                   K   |                                   d{V }t          |          t          k    rt          d          |                    d          st          d          |dd         S )z[
    Read a single line from ``stream``.

    CRLF is stripped from the return value.

    Nzline too longs   
zline without CRLF)readlinelenMAX_LINE_LENGTHr   endswithr"   )r   r@   s     r   r!   r!      sy       """"""""D
4yy?""O,,,==!! ,*+++9r   )r   r   r   r   )r   r   r   r   )r   r   r   r-   )r   r   r   r   )r   r   r   r   )
__future__r   asyncioosredatastructuresr   
exceptionsr   __all__r0   environgetr<   rH   r   compiler=   r1   r   r   r%   r!    r   r   <module>rU      s;   " " " " " "  				 				 $ $ $ $ $ $ & & & & & & ?
+#bjnn%A5IIJJ#bjnn%A6JJKK3 3 3 3 BJ788	 BJ455	. . . .b1( 1( 1( 1(h% % % %P     r   