§
    xÅj2I  ã                  óÔ  — d dl mZ d dlZd dl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lmZ ddlmZmZmZmZmZ ddlmZ g d	¢Z d
j        ej        Ž Zej                             dde› de› �¦  «        Zej                             dde› de› �¦  «        Z eej                             dd¦  «        ¦  «        Z eej                             dd¦  «        ¦  «        Z eej                             dd¦  «        ¦  «        Z d0d„Z! ej"        d¦  «        Z# ej"        d¦  «        Z$ej%         G d„ d¦  «        ¦   «         Z&ej%         G d„ d¦  «        ¦   «         Z'efd1d%„Z(d2d'„Z)d3d/„Z*dS )4é    )ÚannotationsN)Ú	Generator)ÚCallableé   )ÚHeaders)ÚHeaderLineTooLongÚRequestLineTooLongÚSecurityErrorÚStatusLineTooLongÚTooManyHeaders)Ú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_576Úvalueúbytes | bytearrayÚreturnÚstrc                ó.   — |                       d¬¦  «        S )zG
    Decode a bytestring for interpolating into an error message.

    Úbackslashreplace©Úerrors)Údecode)r   s    úBC:\Projects\Historical\venv\Lib\site-packages\websockets/http11.pyÚdr$   8   s   € ð
 �<Š<Ð1ˆ<Ñ2Ô2Ð2ó    s   [-!#$%&\'*+.^_`|~0-9a-zA-Z]+s   [\x09\x20-\x7e\x80-\xff]*c                  óŠ   — e Zd ZU dZded<   ded<   dZded<   dZded	<   d
Zded<   edd„¦   «         Z	e
dd„¦   «         Zdd„Zd
S )r   aé  
    WebSocket handshake request.

    ``method`` and ``path`` must contain only ASCII characters. ``headers``
    should contain only ASCII characters; however, non-ASCII header values are
    tolerated and encoded as ISO-8859-1.

    Attributes:
        path: Request path, including optional query.
        headers: Request headers.
        method: Request method; WebSocket handshake requests use GET.
        protocol: Request protocol; WebSocket handshake requests use HTTP/1.1.
    r   Úpathr   ÚheadersÚGETÚmethodzHTTP/1.1ÚprotocolNúException | NoneÚ
_exceptionr   c                óD   — t          j        dt          ¦  «         | j        S )NzIRequest.exception is deprecated; use ServerProtocol.handshake_exc instead©ÚwarningsÚwarnÚDeprecationWarningr-   ©Úselfs    r#   Ú	exceptionzRequest.exceptionn   s&   € åŒØWÝñ	
ô 	
ð 	
ð ŒÐr%   Ú	read_lineúJCallable[[int, type[Exception]], Generator[None, None, bytes | bytearray]]úGenerator[None, None, Request]c              #  ó   K  — 	 t          |t          ¦  «        E 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vrt	          dt          |¦  «        › �¦  «        ‚|                     d¦  «        }|                     d¦  «        }|                     d¦  «        }	t          |¦  «        E d{V —†}
d	|
v rt          d
¦  «        ‚d|
v r(t          |
d         ¦  «        dk    rt	          d¦  «        ‚ | |	|
||¦  «        S )a¢  
        Parse a WebSocket handshake request.

        This is a generator-based coroutine.

        The request method and path must contain only ASCII characters. The
        request path isn't URL-decoded or validated in any way. Request headers
        should contain only ASCII characters; however, non-ASCII header values
        are tolerated and decoded with ISO-8859-1.

        :meth:`parse` doesn't 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.
            RequestLineTooLong: If the request line is too long.
            HeaderLineTooLong: If a header line is too long.
            TooManyHeaders: If there are too many headers.
            UnicodeDecodeError: If the request method or path isn't ASCII.
            ValueError: If the request isn't well formatted.

        Nz1connection closed while reading HTTP request lineó    é   zinvalid HTTP request line: ©ó   HTTP/1.1s   HTTP/1.0ú5unsupported protocol; expected HTTP/1.1 or HTTP/1.0: ÚasciiúTransfer-Encodingz!transfer codings aren't supportedúContent-Lengthr   zunsupported request body)
Ú
parse_liner	   ÚEOFErrorÚsplitÚ
ValueErrorr$   r"   Úparse_headersÚNotImplementedErrorÚint)Úclsr6   Úrequest_lineÚexcÚ
raw_methodÚraw_pathÚraw_protocolr*   r+   r'   r(   s              r#   ÚparsezRequest.parsev   sÀ  è è € ðP	YÝ&0°Õ<NÑ&OÔ&OÐOÐOÐOÐOÐOÐOˆLˆLøÝð 	Yð 	Yð 	YÝÐNÑOÔOÐUXÐXøøøøð	Yøøøð	XØ1=×1CÒ1CÀDÈ!Ñ1LÔ1LÑ.ˆJ˜ , ,øÝð 	Xð 	Xð 	XÝÐL½1¸\¹?¼?ÐLÐLÑMÔMÐSWÐWð	XøøøàÐ9Ð9Ð9Ýð%Ý�\‘?”?ð%ð %ñô ð ð ×"Ò" 7Ñ+Ô+ˆØ×&Ò& wÑ/Ô/ˆð �Š˜wÑ'Ô'ˆå*¨9Ñ5Ô5Ð5Ð5Ð5Ð5Ð5Ð5ˆð  'Ð)Ð)Ý%Ð&IÑJÔJÐJà˜wÐ&Ð&õ �7Ð+Ô,Ñ-Ô-°Ò2Ð2Ý Ð!;Ñ<Ô<Ð<àˆs�4˜ &¨(Ñ3Ô3Ð3s   „   
?ª:º?ÁA Á+B	Úbytesc                óœ   — | j         › d| j        › d| j        › d�}|                     d¦  «        }|| j                             ¦   «         z  }|S )z;
        Serialize a WebSocket handshake request.

        ú ú
r?   )r*   r'   r+   Úencoder(   Ú	serialize)r4   rJ   Úrequests      r#   rU   zRequest.serializeÂ   sX   € ð œ+ÐGÐG¨¬	ÐGÐG°D´MÐGÐGÐGˆØ×%Ò% gÑ.Ô.ˆØ�4”<×)Ò)Ñ+Ô+Ñ+ˆØˆr%   ©r   r,   )r6   r7   r   r8   ©r   rP   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r*   r+   r-   Úpropertyr5   ÚclassmethodrO   rU   © r%   r#   r   r   T   sÅ   € € € € € € ðð ð €I€I�IØÐÐÑð €FÐÐÐÑØ€HÐÐÐÑð $(€JÐ'Ð'Ð'Ñ'àðð ð ñ „Xðð ðI4ð I4ð I4ñ „[ðI4ðV
ð 
ð 
ð 
ð 
ð 
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d„¦   «         Z
dd„ZdS ) r   aw  
    WebSocket handshake response.

    ``reason_phrase`` and ``headers`` should contain only ASCII characters;
    however, non-ASCII reason phrases and header values are tolerated and
    encoded as ISO-8859-1.

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

    rH   Ústatus_coder   Úreason_phraser   r(   r%   r   ÚbodyNr,   r-   r   c                óD   — t          j        dt          ¦  «         | j        S )NzJResponse.exception is deprecated; use ClientProtocol.handshake_exc insteadr/   r3   s    r#   r5   zResponse.exceptionç   s(   € åŒð7åñ	
ô 	
ð 	
ð
 ŒÐr%   Fr6   r7   Ú
read_exactú9Callable[[int], Generator[None, None, bytes | bytearray]]Úread_to_eofÚproxyÚboolúGenerator[None, None, Response]c              #  ó¦  K  — 	 t          |t          ¦  «        E 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|r$|dvrt	          dt          |¦  «        › �¦  «        ‚n%|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          |	¦  «        › �¦  «        ‚|	 	                    d¦  «        }t          |¦  «        E d{V —†}|rd}nt          |
||||¦  «        E d{V —†} | |
|||¦  «        S )a¡  
        Parse a WebSocket handshake response.

        This is a generator-based coroutine.

        The reason phrase and headers should contain only ASCII characters;
        however, non-ASCII reason phrases and header values are tolerated and
        decoded as ISO-8859-1.

        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.
            StatusLineTooLong: If the status line is too long.
            HeaderLineTooLong: If a header line is too long.
            TooManyHeaders: If there are too many headers.
            SecurityError: If the response body 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>   r=   z)unsupported protocol; expected HTTP/1.1: z+invalid status code; expected integer; got éd   iX  u-   invalid status code; expected 100â€“599; got zinvalid HTTP reason phrase: ú
iso-8859-1r%   )rB   r   rC   rD   rE   r$   rH   Ú	_value_reÚ	fullmatchr"   rF   Ú	read_body)rI   r6   rf   rh   ri   Ústatus_linerK   r+   Úraw_status_codeÚ
raw_reasonrb   Úreasonr(   rd   s                 r#   rO   zResponse.parseð   s¤  è è € ðR	XÝ%/°	Õ;LÑ%MÔ%MÐMÐMÐMÐMÐMÐMˆKˆKøÝð 	Xð 	Xð 	XÝÐMÑNÔNÐTWÐWøøøøð	Xøøøð	VØ4?×4EÒ4EÀdÈAÑ4NÔ4NÑ1ˆH�o z zøÝð 	Vð 	Vð 	VÝÐJ½!¸K¹.¼.ÐJÐJÑKÔKÐQUÐUð	Vøøøàð 
	ØÐ9Ð9Ð9Ý ð(Ý˜‘~”~ð(ð (ñô ð ð :ð ˜;Ò&Ð&Ý ØPÅÀ+ÁÄÐPÐPñô ð ð	Ý˜oÑ.Ô.ˆKˆKøÝð 	ð 	ð 	ÝØR½aÀÑ>PÔ>PÐRÐRñô àðð	øøøð �kÐ'Ð'Ò'Ð' CÒ'Ð'Ð'Ð'ÝØTÅÀ/Ñ@RÔ@RÐTÐTñô ð õ ×"Ò" :Ñ.Ô.ð 	MÝÐK½A¸j¹M¼MÐKÐKÑLÔLÐLð ×"Ò" <Ñ0Ô0ˆå*¨9Ñ5Ô5Ð5Ð5Ð5Ð5Ð5Ð5ˆð ð 	ØˆDˆDå'Ø˜W i°¸[ñô ð ð ð ð ð ð ˆDð ˆs�; ¨°Ñ6Ô6Ð6s(   „   
?ª:º?ÁA Á+B	ÃC( Ã(+DrP   c                ó¢   — d| j         › d| j        › d�}|                     d¦  «        }|| j                             ¦   «         z  }|| j        z  }|S )z<
        Serialize a WebSocket handshake response.

        z	HTTP/1.1 rR   rS   rn   )rb   rc   rT   r(   rU   rd   )r4   rr   Úresponses      r#   rU   zResponse.serializeJ  s_   € ð N $Ô"2ÐMÐM°TÔ5GÐMÐMÐMˆØ×%Ò% lÑ3Ô3ˆØ�D”L×*Ò*Ñ,Ô,Ñ,ˆØ�D”IÑˆØˆr%   rW   )F)
r6   r7   rf   rg   rh   r7   ri   rj   r   rk   rX   )rY   rZ   r[   r\   r]   rd   r-   r^   r5   r_   rO   rU   r`   r%   r#   r   r   Ï   sÊ   € € € € € € ðð ð ÐÐÑØÐÐÑØÐÐÑØ!€DÐ!Ð!Ð!Ñ!à#'€JÐ'Ð'Ð'Ñ'àðð ð ñ „Xðð ð ðW7ð W7ð W7ð W7ñ „[ðW7ðr
ð 
ð 
ð 
ð 
ð 
r%   r   r6   r7   Útoo_long_exc_typeútype[Exception]ú(Generator[None, None, bytes | bytearray]c              #  ó�   K  —  | t           |¦  «        E d{V —†}|                     d¦  «        st          d¦  «        ‚|dd…         S )aä  
    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.
        too_long_exc_type: exception to raise if the line is too long;
            defaults to :exc:`SecurityError`.

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

    Nó   
zline without CRLFéþÿÿÿ)ÚMAX_LINE_LENGTHÚendswithrC   )r6   rx   Úlines      r#   rB   rB   W  s]   è è € ð,  �i¥Ð1BÑCÔCÐCÐCÐCÐCÐCÐC€Dà�=Š=˜Ñ!Ô!ð ,ÝÐ*Ñ+Ô+Ð+Ø���Œ9Ðr%   úGenerator[None, None, Headers]c              #  ó>  K  — t          ¦   «         }t          t          dz   ¦  «        D �][}	 t          | t          ¦  «        E 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¦  «        }|                     ||¦  «         �Œ]t          dt          › d�¦  «        ‚|S )a-  
    Parse HTTP headers.

    Headers should contain only ASCII characters; however, non-ASCII values are
    tolerated and decoded as ISO-8859-1.

    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.
        HeaderLineTooLong: If a header line is too long.
        TooManyHeaders: If there are too many headers.
        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?   rn   zexpected no more than z headers)r   ÚrangeÚMAX_NUM_HEADERSrB   r   rC   rD   rE   r$   Ú	_token_rerp   Ústripro   r"   Úset_insecurer   )	r6   r(   Ú_r€   rK   Úraw_nameÚ	raw_valueÚnamer   s	            r#   rF   rF   t  sÕ  è è € õ4 ‰iŒi€GÝ•? QÑ&Ñ'Ô'ð Qñ Qˆð	TÝ(¨Õ4EÑFÔFÐFÐFÐFÐFÐFÐFˆDˆDøÝð 	Tð 	Tð 	TÝÐIÑJÔJÐPSÐSøøøøð	Tøøøà�3Š;ˆ;Ø‰Eð	OØ"&§*¢*¨T°1Ñ"5Ô"5ÑˆH�i�iøÝð 	Oð 	Oð 	OÝÐC½!¸D¹'¼'ÐCÐCÑDÔDÈ$ÐNð	Oøøøå×"Ò" 8Ñ,Ô,ð 	IÝÐG½!¸H¹+¼+ÐGÐGÑHÔHÐHØ—O’O FÑ+Ô+ˆ	Ý×"Ò" 9Ñ-Ô-ð 	KÝÐI½1¸Y¹<¼<ÐIÐIÑJÔJÐJà�Š˜wÑ'Ô'ˆð × Ò  Ñ.Ô.ˆð 	×Ò˜T 5Ñ)Ô)Ð)Ñ)õ ÐOµoÐOÐOÐOÑPÔPÐPà€Ns#   ¬AÁ
A'ÁA"Á"A'Á4BÂ+B9rb   rH   r(   r   rf   rg   rh   c              #  ó  K  — d| cxk    rdk     sn | dk    s| dk    rdS |                      d¦  «        x}��5|dk    rt          d|› d	�¦  «        ‚d}	 t          |t          ¦  «        E d {V —†}|                     dd¦  «        d         }t          |¦  «        dk    r)|                     d¬¦  «        }	t          d|	› d�¦  «        ‚t          |d¦  «        }
|
dk    rnxt          |¦  «        |
z   t          k    r#t          d|
› dt          |¦  «        › d�¦  «        ‚| ||
¦  «        E d {V —†z  } |d¦  «        E d {V —†dk    rt          d¦  «        ‚�Œt          |¦  «        E d {V —† |S |                      d¦  «        x}�dt          |¦  «        dk    rt          d|› d�¦  «        ‚t          |¦  «        }|t          k    rt          d|› d�¦  «        ‚ ||¦  «        E d {V —†S  |t          t          ¦  «        E d {V —†S )Nrm   éÈ   éÌ   i0  r%   r@   Úchunkedztransfer coding z isn't supportedTó   ;r   r   é   r   r    zchunk too large: 0xz bytesé   zchunk too large: z bytes after r;   r|   zchunk without CRLFrA   é   zbody too large: )ÚgetrG   rB   r
   rD   Úlenr"   rH   ÚMAX_BODY_SIZErE   rF   )rb   r(   r6   rf   rh   Úcodingrd   Úchunk_size_lineÚraw_chunk_sizeÚstr_chunk_sizeÚ
chunk_sizeÚraw_content_lengthÚcontent_lengths                r#   rq   rq   ²  s²  è è € ð ˆkÐÐÒÐ˜CÒÐÐÐ ;°#Ò#5Ð#5¸ÈÒ9KÐ9KØˆsð —K’KÐ 3Ñ4Ô4Ð
4ˆ&Ñ	AØ�YÒÐÝ%Ð&Q¸Ð&QÐ&QÐ&QÑRÔRÐRàˆð	7Ý)3°I½}Ñ)MÔ)MÐMÐMÐMÐMÐMÐMˆOØ,×2Ò2°4¸Ñ;Ô;¸AÔ>ˆNå�>Ñ"Ô" RÒ'Ð'Ø!/×!6Ò!6Ð>PÐ!6Ñ!QÔ!Q�Ý#Ð$P¸.Ð$PÐ$PÐ$PÑQÔQÐQÝ˜^¨RÑ0Ô0ˆJØ˜QŠˆØÝ�4‰yŒy˜:Ñ%­Ò5Ð5Ý#ØR¨
ÐRÐRÅÀTÁÄÐRÐRÐRñô ð ð ˜z˜z¨*Ñ5Ô5Ð5Ð5Ð5Ð5Ð5Ð5Ñ5ˆDØ%˜: a™=œ=Ð(Ð(Ð(Ð(Ð(Ð(¨WÒ4Ð4Ý Ð!5Ñ6Ô6Ð6ñ!	7õ$ ! Ñ+Ô+Ð+Ð+Ð+Ð+Ð+Ð+Ð+Øˆà '§¢Ð,<Ñ =Ô =Ð
=Ð
Ð	JåÐ!Ñ"Ô" RÒ'Ð'ÝÐ MÐ3EÐ MÐ MÐ MÑNÔNÐNÝÐ/Ñ0Ô0ˆØ�MÒ)Ð)ÝÐ I°>Ð IÐ IÐ IÑJÔJÐJØ%˜: nÑ5Ô5Ð5Ð5Ð5Ð5Ð5Ð5Ð6ð '˜;¥}µmÑDÔDÐDÐDÐDÐDÐDÐDÐEr%   )r   r   r   r   )r6   r7   rx   ry   r   rz   )r6   r7   r   r�   )rb   rH   r(   r   r6   r7   rf   rg   rh   r7   r   rz   )+Ú
__future__r   ÚdataclassesÚosÚreÚsysr0   Úcollections.abcr   Útypingr   Údatastructuresr   Ú
exceptionsr   r	   r
   r   r   r   Úwebsockets_versionÚ__all__ÚformatÚversion_infoÚPYTHON_VERSIONÚenvironr•   r   r   rH   r…   r~   r—   r$   Úcompiler†   ro   Ú	dataclassr   r   rB   rF   rq   r`   r%   r#   ú<module>r°      sÒ  ðØ "Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ø 	€	€	€	Ø 	€	€	€	Ø 
€
€
€
Ø €€€Ø %Ð %Ð %Ð %Ð %Ð %Ø Ð Ð Ð Ð Ð à #Ð #Ð #Ð #Ð #Ð #ðð ð ð ð ð ð ð ð ð ð ð ð ð ð 3Ð 2Ð 2Ð 2Ð 2Ð 2ðð ð €ð  �” Ô!1Ð2€ð ŒZ�^Š^ØØ>ˆnÐ>Ð>Ð*<Ð>Ð>ñô €
ð 
Œ�ŠØØ>ˆnÐ>Ð>Ð*<Ð>Ð>ñ
ô 
€ð �#�b”j—n’nÐ%AÀ5ÑIÔIÑJÔJ€ð �#�b”j—n’nÐ%AÀ6ÑJÔJÑKÔK€ð ��B”J—N’NÐ#=¸{ÑKÔKÑLÔL€ð3ð 3ð 3ð 3ð ˆBŒJÐ7Ñ8Ô8€	ð ˆBŒJÐ4Ñ5Ô5€	ð Ôðwð wð wð wð wñ wô wñ Ôðwðt ÔðDð Dð Dð Dð Dñ Dô Dñ ÔðDðV *7ð	ð ð ð ð ð:;ð ;ð ;ð ;ð|;Fð ;Fð ;Fð ;Fð ;Fð ;Fr%   