
    9h;                       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%            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    VC:\Suresh\moveshuttle\MDcreated\moveengine\venv\Lib\site-packages\websockets/http11.pydr   2   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   N   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.exception^   s     W	
 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-Encodingz!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.parsef   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   rI   Request.serialize   s9     =188:<<))++r    returnr$   )r?   -Callable[[int], Generator[None, None, bytes]]rN   zGenerator[None, None, Request]rN   bytes)__name__
__module____qualname____firstlineno____doc____annotations__r%   propertyr-   classmethodrE   rI   __static_attributes__rL   r   r   r   r   N   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S j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.

intstatus_coder!   reason_phraser   r#   r   rQ   bodyNr$   r%   c                P    [         R                  " S[        5        U R                  $ )NzJResponse.exception is deprecated; use ClientProtocol.handshake_exc insteadr'   r+   s    r   r-   Response.exception   s"    7	

 r   c              #    #     [        U5       Sh  vN n UR                  SS5      u  pxn	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U(       a  [        XXU5       Sh  vN nOSn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! [         a    [        S[	        U5       35      Sef = f N N~7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   r   )r8   r9   r:   r;   r   r]   	_value_re	fullmatchr   r<   	read_body)r>   r?   
read_exactread_to_eofinclude_bodystatus_linerA   rD   raw_status_code
raw_reasonr^   reasonr#   r`   s                 r   rE   Response.parse   s    B	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[ D D;66G ; 	XMNTWW	X
  	V9!K.9IJKQUU	V  	=a>P=QR	 6s   E*C< C:C< D E*E  A7E*E&E*)E(*E*:C< <
DDDE*#D==E* #E##E*(E*c                    SU R                    SU R                   S3R                  5       nXR                  R	                  5       -  nXR
                  -  nU$ )z,
Serialize a WebSocket handshake response.

z	HTTP/1.1  z
)r^   r_   rH   r#   rI   r`   )r,   responses     r   rI   Response.serialize  sU     t//0$2D2D1ETJQQSLL**,,IIr   rL   rM   )T)
r?   rO   rh   rO   ri   rO   rj   boolrN   zGenerator[None, None, Response]rP   )rR   rS   rT   rU   rV   rW   r`   r%   rX   r-   rY   rE   rI   rZ   rL   r   r   r   r      s    	 D%#'J '   "D7@D7 BD7 C	D7
 D7 
)D7 D7L
r   r   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 long   
zline without CRLF)MAX_LINE_LENGTHRuntimeErrorr   endswithr9   )r?   lines     r   r8   r8   #  s^     "-#O44 ==!!*++9 5 -O,,-s)   AA  >A  &AA   AA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_HEADERSr8   r9   r:   r;   r   	_token_rerf   stripre   r   r   )	r?   r#   _r{   rA   raw_name	raw_valuenamer   s	            r   r<   r<   >  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              #    #    SU s=::  a  S:  d  O  U S:X  d  U S:X  a  gUR                  S5      =nb  US:w  a  [        SU S	35      eSn [        U5       S h  vN nUR                  S
S5      S   n[	        U5      S:  a  UR                  SS9n	[        SU	 S35      e[        US5      n
U
S:X  a  Od[	        U5      U
-   [        :  a  [        SU
 S[	        U5       S35      eXc" U
5       S h  vN -  nU" S5       S h  vN S:w  a  [        S5      eM  [        U5       S h  vN   U$ UR                  S5      =nbR  [	        U5      S:  a  [        SU S35      e[        U5      nU[        :  a  [        SU S35      eU" U5       S h  vN $  U" [        5       S h  vN $  GNN N N N N" N! [         a    [        S[         S35      ef = f7f)Nrd         i0  r   r6   chunkedztransfer coding z isn't supported   ;r   r      r   r   zchunk too large: 0xz bytes   zchunk too large: z bytes after r1   rv   zchunk without CRLFr7      zbody too large: zbody too large: over )getr=   r8   r:   lenr   r   r]   MAX_BODY_SIZEr;   r<   ry   )r^   r#   r?   rh   ri   codingr`   chunk_size_lineraw_chunk_sizestr_chunk_size
chunk_sizeraw_content_lengthcontent_lengths                r   rg   rg   q  s     kC;##59K KK 34
4&	AY%(8@P&QRR)3I)>>O,224;A>N>"R'!/!6!6>P!6!Q#&9.9I$PQQ^R0JQ4y:%5#'
|=T6R  z*555D%a=(W4 !566! $ !+++ ',< =
=
	J!"R'"23E2Ff MNN/0M)"2>2B& IJJ%n556	O*=99:? ? 6( 	, 6 : 	O"7f MNN	Os   AGF'BG/F*0GF,#G%F.&A'GF0GF4 "F2#F4 &G*G,G.G0G2F4 4GG)r   rQ   rN   r!   )r?   rO   rN   Generator[None, None, bytes])r?   rO   rN   zGenerator[None, None, Headers])r^   r]   r#   r   r?   rO   rh   rO   ri   rO   rN   r   )'
__future__r   dataclassesosresysr(   collections.abcr   typingr   datastructuresr   
exceptionsr   r	   websockets_version__all__formatversion_infoPYTHON_VERSIONenvironr   r   r
   r]   r   rx   r   r   compiler   re   	dataclassr   r   r8   r<   rg   rL   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	 ` ` `F m m m`<!60<0#0f:O:O:O =:O >	:O
 ?:O ":Or   