
    vKg[4                       S SK Jr  S SKrS SK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KJr  SSKJr  SSKJr  / S	QrS
R$                  " \R&                  6 r\R*                  R-                  SS\ S\ 35      r\R*                  R-                  SS\ S\ 35      r\" \R*                  R-                  SS5      5      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 \RB                   " S S5      5       r"\RB                   " S S5      5       r#    SS jr$    S S jr%g)!    )annotationsN)	Generator)Callable   )Headers)SecurityError)version)SERVER
USER_AGENTRequestResponsez{}.{}WEBSOCKETS_USER_AGENTzPython/z websockets/WEBSOCKETS_SERVERWEBSOCKETS_MAX_NUM_HEADERS128WEBSOCKETS_MAX_LINE_LENGTH8192WEBSOCKETS_MAX_BODY_SIZE	1_048_576c                     U R                  SS9$ )z?
Decode a bytestring for interpolating into an error message.

backslashreplace)errors)decode)values    Q/var/www/highfloat_scraper/venv/lib/python3.13/site-packages/websockets/http11.pydr   -   s    
 <<1<22    s   [-!#$%&\'*+.^_`|~0-9a-zA-Z]+s   [\x09\x20-\x7e\x80-\xff]*c                  v    \ rS rSr% SrS\S'   S\S'   SrS\S	'   \SS
 j5       r\	    SS j5       r
SS jrSrg)r   I   z{
WebSocket handshake request.

Attributes:
    path: Request path, including optional query.
    headers: Request headers.
strpathr   headersNException | None
_exceptionc                P    [         R                  " S[        5        U R                  $ )NzIRequest.exception is deprecated; use ServerProtocol.handshake_exc insteadwarningswarnDeprecationWarningr$   selfs    r   	exceptionRequest.exceptionY   "    7	

 r   c              #     #     [        U5       Sh  vN n UR                  SS5      u  pEn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       Sh  vN nSU;   a  [        S5      eSU;   a  [        S5      eU " Xx5      $  N! [         a  n[        S5      UeSnAff = f! [         a    [        S[	        U5       35      Sef = f Nt7f)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       zinvalid HTTP request line:    HTTP/1.1)unsupported protocol; expected HTTP/1.1: s   GETz+unsupported HTTP method; expected GET; got asciisurrogateescapeTransfer-Encoding!transfer codings aren't supportedContent-Lengthzunsupported request body)
parse_lineEOFErrorsplit
ValueErrorr   r   parse_headersNotImplementedError)	cls	read_linerequest_lineexcmethodraw_pathprotocolr!   r"   s	            r   parseRequest.parseb   s(    F	Y&0&;;L	X)5););D!)D&Fh {";AlO;LM  VJ1V9+VWWw(9:*955 ')%&IJJw&7884!!5 < 	YNOUXX	Y
  	X:1\?:KLMSWW	X 6sU   C>B8 B6B8 C AC>C<.C>6B8 8
CCCC>#C99C>c                z    SU R                    S3R                  5       nXR                  R                  5       -  nU$ )z+
Serialize a WebSocket handshake request.

zGET z HTTP/1.1
)r!   encoder"   	serialize)r+   requests     r   rJ   Request.serialize   s9     =188:<<))++r    returnr#   )r@   -Callable[[int], Generator[None, None, bytes]]rO   zGenerator[None, None, Request]rO   bytes)__name__
__module____qualname____firstlineno____doc____annotations__r$   propertyr,   classmethodrF   rJ   __static_attributes__rM   r   r   r   r   I   s_     I $(J '  ="@=" 
(=" ="~	r   r   c                      \ rS rSr% SrS\S'   S\S'   S\S'   S	rS
\S'   S	rS\S'   \SS j5       r	\
        SS j5       rSS jrSrg	)r      z
WebSocket handshake response.

Attributes:
    status_code: Response code.
    reason_phrase: Response reason.
    headers: Response headers.
    body: Response body, if any.

intstatus_coder    reason_phraser   r"   Nzbytes | Nonebodyr#   r$   c                P    [         R                  " S[        5        U R                  $ )NzJResponse.exception is deprecated; use ClientProtocol.handshake_exc insteadr&   r*   s    r   r,   Response.exception   r.   r   c              #  
  #     [        U5       Sh  vN n UR                  SS5      u  pgn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                  SS5      n
[        U5       Sh  vN nSU;   a  [        S5      eS	U	s=::  a  S:  d  O  U	S:X  d  U	S:X  a  SnOS US   n[        U5      nUc   U" [        5       Sh  vN nO)U[        :  a  [        SU S35      eU" U5       Sh  vN nU " XX5      $  GNK! [         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 N! [         a    Sn Nf = f N! [         a    [        S[         S35      ef = f N7f)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 liner0   r1   zinvalid HTTP status line: r2   r3   z+invalid status code; expected integer; got d   iX  u-   invalid status code; expected 100–599; got zinvalid HTTP reason phrase: r4   r5   r6   r7         i0  r8   zbody too large: over z byteszbody too large: )r9   r:   r;   r<   r   r^   	_value_re	fullmatchr   r=   r>   KeyErrorMAX_BODY_SIZERuntimeErrorr   )r?   r@   
read_exactread_to_eofstatus_linerB   rE   raw_status_code
raw_reasonr_   reasonr"   ra   raw_content_lengthcontent_lengths                  r   rF   Response.parse   s\    @	X%/	%::K	V4?4E4EdA4N1Hz {";AkN;KL 	o.K
 k'C'?/@R?ST  "":..;AjM?KLL""7,=>*955 ')%&IJJ +##{c'9[C=OD9 &--=%>" "%%7!8%W&1-&@@D  -/#&6~6Ff$MNN",^"<<;66w ; 	XMNTWW	X
  	V9!K.9IJKQUU	V  	=a>P=QR	 6$  &!%& A# W'*?f(UVVW
 =s   HE  EE  E> HF$ A7HG
3HG HG  %G&G  *%HHHE   
E;*E66E;;H>#F!!H$#GHGHGHG   G>>Hc                    SU R                    SU R                   S3R                  5       nXR                  R	                  5       -  nU R
                  b  XR
                  -  nU$ )z,
Serialize a WebSocket handshake response.

z	HTTP/1.1  z
)r_   r`   rI   r"   rJ   ra   )r+   responses     r   rJ   Response.serialize)  s_     t//0$2D2D1ETJQQSLL**,,99 		!Hr   rM   rN   )r@   rP   rm   rP   rn   rP   rO   zGenerator[None, None, Response]rQ   )rS   rT   rU   rV   rW   rX   ra   r$   rY   r,   rZ   rF   rJ   r[   rM   r   r   r   r      s    	 D,#'J '  [7@[7 B[7 C	[7
 
)[7 [7zr   r   c              #    #    [        5       n[        [        S-   5       H  n [        U 5       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)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.

r   Nz,connection closed while reading HTTP headersr      :zinvalid HTTP header line: zinvalid HTTP header name: s    	zinvalid HTTP header value: r4   r5   ztoo many HTTP headers)r   rangeMAX_NUM_HEADERSr9   r:   r;   r<   r   	_token_reri   striprh   r   r   )	r@   r"   _linerB   raw_name	raw_valuenamer   s	            r   r=   r=   7  sG    , iG?Q&'	T(33D 3;& N#	O"&**T1"5H ""8,,9!H+GHHOOF+	""9--:1Y<.IJJw'  *;<) (. 34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 " [         5       Sh  vN nUR                  S5      (       d  [	        S5      eUSS $  N*! [         a    [        S5      ef = f7f)aK  
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 longs   
zline without CRLF)MAX_LINE_LENGTHrl   r   endswithr:   )r@   r   s     r   r9   r9   j  s^     "-#O44 ==!!*++9 5 -O,,-s)   AA  >A  &AA   AA)r   rR   rO   r    )r@   rP   rO   zGenerator[None, None, Headers])r@   rP   rO   zGenerator[None, None, bytes])&
__future__r   dataclassesosresysr'   collections.abcr   typingr   datastructuresr   
exceptionsr   r	   websockets_version__all__formatversion_infoPYTHON_VERSIONenvirongetr   r
   r^   r}   r   rk   r   compiler~   rh   	dataclassr   r   r=   r9   rM   r   r   <module>r      s   "  	 	 
  %  # % 2 : !1!12 ZZ^^n\*<)=>
 
n\*<)=>
 bjjnn%A5IJ bjjnn%A6JK BJJNN#={KL3 JJ78	 JJ45	 a a aH E E EP0<0#0f<!r   