Ë
    RPf1  ã                  ó,  — d dl mZ d dlZd dlZd dlZd dlmZmZmZ ddl	m
Z
mZ dZdZdZdd	„Z ej                   d
«      Z ej                   d«      Zej&                   G d„ d«      «       Zej&                   G d„ d«      «       Z	 	 	 	 dd„Z	 	 	 	 dd„Zy)é    )ÚannotationsN)ÚCallableÚ	GeneratorÚOptionalé   )ÚdatastructuresÚ
exceptionsé€   i    i   c                ó&   — | j                  d¬«      S )zG
    Decode a bytestring for interpolating into an error message.

    Úbackslashreplace)Úerrors)Údecode)Úvalues    úK/var/www/fastapitest/venv/lib/python3.12/site-packages/websockets/http11.pyÚdr      s   € ð
 �<‰<Ð1ˆ<Ó2Ð2ó    s   [-!#$%&\'*+.^_`|~0-9a-zA-Z]+s   [\x09\x20-\x7e\x80-\xff]*c                  óh   — e Zd ZU dZded<   ded<   dZded<   edd	„«       Ze	 	 	 	 dd
„«       Z	dd„Z
y)ÚRequestz�
    WebSocket handshake request.

    Attributes:
        path: Request path, including optional query.
        headers: Request headers.
    ÚstrÚpathúdatastructures.HeadersÚheadersNúOptional[Exception]Ú
_exceptionc                óN   — t        j                  dt        «       | j                  S )NzIRequest.exception is deprecated; use ServerProtocol.handshake_exc instead©ÚwarningsÚwarnÚDeprecationWarningr   ©Úselfs    r   Ú	exceptionzRequest.exceptionC   ó"   € ä�‰ð7äô	
ð
 �‰Ðr   c              #  óô  K  — 	 t        |«      E d{  –—† }	 |j                  dd«      \  }}}|dk7  rt        dt	        |«      › �«      ‚|dk7  rt        d	t	        |«      › �«      ‚|j                  d
d«      }t        |«      E d{  –—† }d|v rt        d«      ‚d|v rt        d«      ‚ | ||«      S 7 ŒŸ# t        $ r}t        d«      |‚d}~ww xY w# t        $ r t        dt	        |«      › �«      d‚w xY w7 Œo­w)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: s   GETzunsupported HTTP method: ó   HTTP/1.1úunsupported HTTP version: Ú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Úversionr   r   s	            r   ÚparsezRequest.parseL   s&  è ø€ ðF	YÜ&0°Ó&;×;ˆLð	XØ(4×(:Ñ(:¸4ÀÓ(CÑ%ˆF�H˜gð �VÒÜÐ8¼¸6»¸ÐDÓEÐEØ�kÒ!ÜÐ9¼!¸G»*¸ÐFÓGÐGØ�‰˜wÐ(9Ó:ˆä*¨9Ó5×5ˆð  'Ñ)Ü%Ð&IÓJÐJà˜wÑ&ÜÐ7Ó8Ð8á�4˜Ó!Ð!ð3 <ùÜò 	YÜÐNÓOÐUXÐXûð	Yûô
 ò 	XÜÐ:¼1¸\»?Ð:KÐLÓMÐSWÐWð	Xúð 6úsU   ‚C8„B4 ’B2“B4 ˜C ®AC8ÂC6Â+C8Â2B4 Â4	CÂ=C	Ã	CÃC8Ã"C3Ã3C8c                ó|   — d| j                   › d�j                  «       }|| j                  j                  «       z  }|S )z;
        Serialize a WebSocket handshake request.

        zGET z HTTP/1.1
)r   Úencoder   Ú	serialize)r!   Úrequests     r   r>   zRequest.serialize‹   s;   € ð ˜Ÿ™˜ =Ð1×8Ñ8Ó:ˆØ�4—<‘<×)Ñ)Ó+Ñ+ˆØˆr   ©Úreturnr   )r5   ú-Callable[[int], Generator[None, None, bytes]]rA   zGenerator[None, None, Request]©rA   Úbytes)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r   Úpropertyr"   Úclassmethodr;   r>   © r   r   r   r   3   s_   … ñð ƒIØ#Ó#ð '+€JÐ#Ó*àòó ðð ð<"à@ð<"ð 
(ò<"ó ð<"ô|	r   r   c                  óˆ   — e Zd ZU dZded<   ded<   ded<   dZd	ed
<   dZded<   edd„«       Ze		 	 	 	 	 	 	 	 dd„«       Z
dd„Zy)ÚResponsezÍ
    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Optional[bytes]Úbodyr   r   c                óN   — t        j                  dt        «       | j                  S )NzJResponse.exception is deprecated; use ClientProtocol.handshake_exc insteadr   r    s    r   r"   zResponse.exception«   r#   r   c              #  ó
  K  — 	 t        |«      E d{  –—† }	 |j                  dd«      \  }}}|dk7  rt        dt	        |«      › �«      ‚	 t        |«      }	d	|	cxk  rd
k  sn t        dt	        |«      › �«      ‚t        j                  |«      st        dt	        |«      › �«      ‚|j                  «       }
t        |«      E d{  –—† }d|v rt        d«      ‚d	|	cxk  rdk  sn |	dk(  s|	dk(  rd}n[	 |d   }t        |«      }|€	  |t        «      E d{  –—† }n2|t        kD  rt        j                  d|› d�«      ‚ ||«      E d{  –—† } | |	|
||«      S 7 �ŒF# t        $ r}t        d«      |‚d}~ww xY w# t        $ r t        dt	        |«      › �«      d‚w xY w# t        $ r t        dt	        |«      › �«      d‚w xY w7 Œý# t        $ r d}Y ŒÎw xY w7 Œ¿# t        $ r t        j                  dt        › d�«      ‚w xY w7 Œ¸­w)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%   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,   éÈ   éÌ   i0  r-   zbody too large: over z byteszbody too large: )r.   r/   r0   r1   r   rO   Ú	_value_reÚ	fullmatchr   r2   r3   ÚKeyErrorÚMAX_BODYÚRuntimeErrorr	   ÚSecurityError)r4   r5   Ú
read_exactÚread_to_eofÚstatus_liner7   r:   Úraw_status_codeÚ
raw_reasonrP   Úreasonr   rR   Úraw_content_lengthÚcontent_lengths                  r   r;   zResponse.parse´   sb  è ø€ ð@	XÜ%/°	Ó%:×:ˆKð	VØ3>×3DÑ3DÀTÈ1Ó3MÑ0ˆG�_ jð �kÒ!ÜÐ9¼!¸G»*¸ÐFÓGÐGð	Ü˜oÓ.ˆKð
 �kÔ( DÔ(ÜÐ=¼aÀÓ>PÐ=QÐRÓSÐSÜ×"Ñ" :Ô.ÜÐ;¼A¸j»M¸?ÐKÓLÐLØ×"Ñ"Ó$ˆä*¨9Ó5×5ˆð  'Ñ)Ü%Ð&IÓJÐJð �+Ô# Ô# {°cÒ'9¸[ÈCÒ=OØ‰Dð9ð &-Ð-=Ñ%>Ð"ô "%Ð%7Ó!8�àÐ%ðÙ&1´(Ó&;×;‘Dð
  ¤(Ò*Ü ×.Ñ.Ø& ~Ð&6°fÐ=óð ñ #-¨^Ó"<×<�á�; ¨°Ó6Ð6ðy ;úÜò 	XÜÐMÓNÐTWÐWûð	Xûô
 ò 	VÜÐ9¼!¸K».Ð9IÐJÓKÐQUÐUð	Vûô ò 	ÜØ,¬Q¨Ó-?Ð,@ÐAóàðð	úð 6ùô$ ò &Ø!%’ð&úð <ùÜ#ò Ü$×2Ñ2Ø/´¨z¸Ð@óð ðúð =úsÇ   ‚H„E ’E“E ˜E8 ®HÁF ÁA.HÃGÃ-HÃ3G Ã8HÄG ÄGÄG Ä.HÅHÅ	HÅE Å	E5Å$E0Å0E5Å5HÅ8"FÆHÆ"F?Æ?HÇGÇHÇGÇHÇG Ç'G>Ç>Hc                óÌ   — d| j                   › d| j                  › d�j                  «       }|| j                  j	                  «       z  }| j
                  �|| j
                  z  }|S )z<
        Serialize a WebSocket handshake response.

        z	HTTP/1.1 ú z
)rP   rQ   r=   r   r>   rR   )r!   Úresponses     r   r>   zResponse.serialize  sc   € ð ˜t×/Ñ/Ð0°°$×2DÑ2DÐ1EÀTÐJ×QÑQÓSˆØ�D—L‘L×*Ñ*Ó,Ñ,ˆØ�9‰9Ð Ø˜Ÿ	™	Ñ!ˆHØˆr   r@   )r5   rB   r^   rB   r_   rB   rA   zGenerator[None, None, Response]rC   )rE   rF   rG   rH   rI   rR   r   rJ   r"   rK   r;   r>   rL   r   r   rN   rN   —   sŠ   … ñ	ð ÓØÓØ#Ó#Ø €Dˆ/Ó à&*€JÐ#Ó*àòó ðð ð\7à@ð\7ð Bð\7ð Cð	\7ð
 
)ò\7ó ð\7ô|r   rN   c              #  ó˜  K  — t        j                  «       }t        t        dz   «      D ]Å  }	 t	        | «      E d{  –—† }|dk(  r |S 	 |j                  dd«      \  }}t        j                  |«      st        dt        |«      › �«      ‚|j                  d«      }t        j                  |«      st        d	t        |«      › �«      ‚|j                  d
«      }|j                  d
d«      }|||<   ŒÇ t        j                  d«      ‚7 ŒÊ# t
        $ r}t        d«      |‚d}~ww xY w# t        $ r t        dt        |«      › �«      d‚w xY w­w)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: r)   r*   ztoo many HTTP headers)r   ÚHeadersÚrangeÚMAX_HEADERSr.   r/   r0   r1   r   Ú	_token_rerY   ÚstriprX   r   r	   r]   )	r5   r   Ú_Úliner7   Úraw_nameÚ	raw_valueÚnamer   s	            r   r2   r2   !  sY  è ø€ ô, ×$Ñ$Ó&€GÜ”; ‘?Ó#ò @ˆð	TÜ(¨Ó3×3ˆDð �3Š;Øð& €Nð#	OØ"&§*¡*¨T°1Ó"5ÑˆH�iô ×"Ñ" 8Ô,ÜÐ9¼!¸H»+¸ÐGÓHÐHØ—O‘O FÓ+ˆ	Ü×"Ñ" 9Ô-ÜÐ:¼1¸Y»<¸.ÐIÓJÐJà�‰˜wÓ'ˆØ× Ñ  Ð*;Ó<ˆØˆ�Šð)@ô. ×&Ñ&Ð'>Ó?Ð?ð+ 4ùÜò 	TÜÐIÓJÐPSÐSûð	Tûô ò 	OÜÐ9¼!¸D»'¸ÐCÓDÈ$ÐNð	OüsQ   ‚*E
­D»D¼DÁ E
Á	D%ÁB(E
ÄDÄ	D"ÄDÄD"Ä"E
Ä%"EÅE
c              #  ó¾   K  — 	  | t         «      E d{  –—† }|j	                  d«      st        d«      ‚|dd S 7 Œ%# t        $ r t        j                  d«      ‚w xY w­w)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 longs   
zline without CRLFéþÿÿÿ)ÚMAX_LINEr\   r	   r]   Úendswithr/   )r5   rq   s     r   r.   r.   T  sb   è ø€ ð"8Ù#¤HÓ-×-ˆð �=‰=˜Ô!ÜÐ*Ó+Ð+Ø��ˆ9Ðð .ùÜò 8Ü×&Ñ& Ó7Ð7ð8üs%   ‚A„; “9”; ˜!A¹; »AÁA)r   rD   rA   r   )r5   rB   rA   z-Generator[None, None, datastructures.Headers])r5   rB   rA   zGenerator[None, None, bytes])Ú
__future__r   ÚdataclassesÚrer   Útypingr   r   r   Ú r   r	   rm   rw   r[   r   Úcompilern   rX   Ú	dataclassr   rN   r2   r.   rL   r   r   ú<module>r€      sË   ðÝ "ã Û 	Û ß 0Ñ 0ç (ð €ð €ð €ó3ð ˆB�J‰JÐ7Ó8€	ð ˆB�J‰JÐ4Ó5€	ð ×Ñ÷`ð `ó ð`ðF ×Ñ÷Fð Fó ðFðR0Ø<ð0à2ó0ðfØ<ðà!ôr   