
    vKg                    J   S SK Jr  S SKrS SKrS SKrSSKJr  SSKJr  SS/r	\
" \R                  R                  SS	5      5      r\
" \R                  R                  S
S5      5      rSS jr\R                   " S5      r\R                   " S5      rSS jrSS jrSS jrSS jrg)    )annotationsN   )Headers)SecurityErrorread_requestread_responseWEBSOCKETS_MAX_NUM_HEADERS128WEBSOCKETS_MAX_LINE_LENGTH8192c                     U R                  SS9$ )z?
Decode a bytestring for interpolating into an error message.

backslashreplace)errors)decode)values    V/var/www/highfloat_scraper/venv/lib/python3.13/site-packages/websockets/legacy/http.pydr      s    
 <<1<22    s   [-!#$%&\'*+.^_`|~0-9a-zA-Z]+s   [\x09\x20-\x7e\x80-\xff]*c                  #     [        U 5      I Sh  vN n UR                  SS5      u  p4nUS:w  a  [        S[	        U5       35      eUS:w  a  [        S	[	        U5       35      eUR                  S
S5      n[        U 5      I Sh  vN nXg4$  N|! [         a  n[        S5      UeSnAff = f! [         a    [        S[	        U5       35      Sef = f NM7f)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)streamrequest_lineexcmethodraw_pathversionpathheaderss           r   r   r   -   s     8U&v..T$0$6$6tQ$?!' 4QvYK@AA+5aj\BCC??7$56D ((G=# / UJKQTTU
  T6q6GHItST )sU   CB BB B/ ACCCB 
B,B''B,,C/#CCc                  #     [        U 5      I Sh  vN n UR                  SS5      u  p4nUS:w  a  [        S[	        U5       35      e [        U5      nS	Us=::  a  S
:  d  O  [        S[	        U5       35      e[        R                  U5      (       d  [        S[	        U5       35      eUR                  5       n[        U 5      I Sh  vN nXgU4$  N! [         a  n[        S5      UeSnAff = f! [         a    [        S[	        U5       35      Sef = f! [         a    [        S[	        U5       35      Sef = f Nt7f)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   ^   sa    2T%f--R/:/@/@q/I,* +5aj\BCCV/* +$$9!O:L9MNOOz**7*GHH F ((G''/ . TIJPSST
  R5an5EFGTQR  V5a6H5IJKQUUV )sm   EC CC C4 ED A5EE EC 
C1 C,,C11E4#DE#D==Ec                  #    [        5       n[        [        S-   5       H  n [        U 5      I Sh  vN nUS:X  a    U$  UR                  SS5      u  pV[        R                  U5      (       d  [        S[        U5       35      eUR                  S5      n[        R                  U5      (       d  [        S	[        U5       35      eUR                  S
5      nUR                  S
S5      nXU'   M     [        S5      e N! [         a  n[	        S5      UeSnAff = f! [         a    [        S[        U5       35      Sef = f7f)zc
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_rer,   stripr+   r   r   )	r    r'   _liner"   raw_name	raw_valuenamer   s	            r   r   r      sG     iG?Q&'	T"6**D 3;& N#	O"&**T1"5H ""8,,9!H+GHHOOF+	""9--:1Y<.IJJw'  *;<) (. 344+ + 	TIJPSS	T  	O9!D'CD$N	OsP    EC?C=C?	E DB)E=C??
D	DDE#E  Ec                   #    U R                  5       I Sh  vN n[        U5      [        :  a  [        S5      eUR	                  S5      (       d  [        S5      eUSS $  NH7f)zO
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
4y?"O,,==!!*++9 #s   A!AA	A!)r   bytesreturnstr)r    asyncio.StreamReaderrE   ztuple[str, Headers])r    rG   rE   ztuple[int, str, Headers])r    rG   rE   r   )r    rG   rE   rD   )
__future__r   asyncioosredatastructuresr   
exceptionsr   __all__r*   environgetr6   rB   r   compiler7   r+   r   r   r   r    r   r   <module>rS      s    "  	 	 $ & ?
+bjjnn%A5IJbjjnn%A6JK3 JJ78	 JJ45	.b1(h%Pr   