Your IP : 3.147.53.214


Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/aiohttp/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/aiohttp/__pycache__/web_ws.cpython-311.pyc

�

��bg�H����UddlZddlZddlZddlZddlZddlZddlmZmZm	Z	m
Z
mZmZddl
Z
ddlmZddlmZddlmZddlmZmZddlmZmZmZmZmZmZmZmZm Z m!Z!m"Z"dd	l#m$Z$dd
l%m&Z&m'Z'ddl(m)Z)m*Z*ddl+m,Z,m-Z-dd
l.m/Z/ddl0m1Z1ej2dkrddlZ3nddl3Z3dZ4dZ5ee6e7d<e
j8ddd���Gd�d����Z9Gd�de1��Z:dS)�N)�Any�Final�Iterable�Optional�Tuple�cast)�CIMultiDict�)�hdrs)�AbstractStreamWriter)�
call_later�
set_result)�WS_CLOSED_MESSAGE�WS_CLOSING_MESSAGE�WS_KEY�WebSocketError�WebSocketReader�WebSocketWriter�WSCloseCode�	WSMessage�	WSMsgType�
ws_ext_gen�ws_ext_parse)�	ws_logger)�	EofStream�FlowControlDataQueue)�JSONDecoder�JSONEncoder)�HTTPBadRequest�
HTTPException)�BaseRequest)�StreamResponse)��)�WebSocketResponse�WebSocketReadyr��THRESHOLD_CONNLOST_ACCESST)�auto_attribs�frozen�slotsc�<�eZdZUeed<eeed<defd�ZdS)r&�ok�protocol�returnc��|jS�N)r-��selfs �E/opt/cloudlinux/venv/lib64/python3.11/site-packages/aiohttp/web_ws.py�__bool__zWebSocketReady.__bool__6s	���w��N)�__name__�
__module__�__qualname__�bool�__annotations__r�strr5�r6r4r&r&1sJ��������H�H�H��s�m�����$������r6r&c���eZdZdZddddddddd�ded	eed
ededeed
eedede	ddf�fd�Z
dCd�ZdCd�ZdCd�Z
dCd�Zdedef�fd�Zdededeeeffd�Zdedeeeffd�Zdedededdfd�Zdedefd�Zedefd���Zedee	fd ���Zedeefd!���Zedefd"���ZdDd#ed$edefd%�Zdee fd&�Z!dEd(e"ddfd)�Z#dEd(e"ddfd*�Z$dDd+edeeddfd,�Z%dDd+e"deeddfd-�Z&	dDe'j(d.�d+edeed/e)ddfd0�Z*dCd1�Z+e,j-d'dd2�d3e	d(e"d4edefd5�Z.d3e,ddfd6�Z/dDdeede0fd7�Z1dd8�deedefd9�Z2dd8�deede"fd:�Z3e'j4dd;�d<e5deedefd=�Z6d+e"ddfd>�Z7dFd?�Z8de0fd@�Z9dAe ddfdB�Z:�xZ;S)Gr%Fg$@NTr=i@)�timeout�receive_timeout�	autoclose�autoping�	heartbeat�	protocols�compress�max_msg_sizer?r@rArBrCrDrErFr/c�|��t���d���||_d|_d|_d|_d|_d|_d|_d|_	d|_
d|_d|_||_
||_||_||_||_d|_|�
|dz|_d|_||_||_dS)N�e)�statusFrg@)�super�__init__�
_protocols�_ws_protocol�_writer�_reader�_closed�_closing�
_conn_lost�_close_code�_loop�_waiting�
_exception�_timeout�_receive_timeout�
_autoclose�	_autoping�
_heartbeat�
_heartbeat_cb�_pong_heartbeat�_pong_response_cb�	_compress�
_max_msg_size)
r3r?r@rArBrCrDrErF�	__class__s
         �r4rKzWebSocketResponse.__init__>s����	�������$�$�$�#���+/���26���BF��������
����*.���:>��
�8<��
�37�����
� /���#���!���#���<@���� �#,�s�?�D� �@D���!���)����r6c��|j� |j���d|_|j�"|j���d|_dSdSr1)r^�cancelr\r2s r4�_cancel_heartbeatz#WebSocketResponse._cancel_heartbeatbs\���!�-��"�)�)�+�+�+�%)�D�"���)���%�%�'�'�'�!%�D����*�)r6c���|���|j�J|j�J�t|j|j|j|j�|jjjnd���|_dSdS�Nr')�timeout_ceil_threshold)	rdr[rTr
�_send_heartbeat�_req�	_protocol�_timeout_ceil_thresholdr\r2s r4�_reset_heartbeatz"WebSocketResponse._reset_heartbeatksz����� � � ��?�&��:�)�)�)�!+��$����
��9�(�(,�y�':�'R�'R��
"�"�"�D����'�&r6c�\�|j��|js�|j�J�|j�|j�����|j�|j���t|j	|j
|j|j�|jjj
nd���|_dSdSdSrf)r[rPrT�create_taskrN�pingr^rcr
�_pong_not_receivedr]rirjrkr2s r4rhz!WebSocketResponse._send_heartbeatys����?�&�t�|�&��:�)�)�)�
�J�"�"�4�<�#4�#4�#6�#6�7�7�7��%�1��&�-�-�/�/�/�%/��'��$��
��9�(�(,�y�':�'R�'R��
&�&�&�D�"�"�"�'�&�&�&r6c��|j�L|jj�Bd|_|�tj��t
j��|_dSdSdS)NT)	ri�	transportrP�_set_code_close_transportr�ABNORMAL_CLOSURE�asyncio�TimeoutErrorrVr2s r4rpz$WebSocketResponse._pong_not_received�sT���9� �T�Y�%8�%D��D�L��*�*�;�+G�H�H�H�%�2�4�4�D�O�O�O�!� �%D�%Dr6�requestc���K�|j�|jS|�|��\}}t���|���d{V��}|�J�|�|||��|����d{V��|Sr1)�_payload_writer�
_pre_startrJ�prepare�_post_start�drain)r3rwr.�writer�payload_writerras     �r4r{zWebSocketResponse.prepare�s��������+��'�'��?�?�7�3�3���&�$�w�w���w�7�7�7�7�7�7�7�7���)�)�)�����(�F�3�3�3��"�"�$�$�$�$�$�$�$�$�$��r6zCIMultiDict[str]c�p�|j}d|�tjd��������kr@t
d�|�tj��������d|�tjd�����vr@t
d�|�tj��������d}tj	|vr\d�|tj	�
d��D��}|D]}||jvr|}n�tj
d	||j��|�tjd��}|d
vrt
d|������|�tj��}	|r%t!t#j|����dkrt
d
|������n'#t&j$rt
d
|�����d�wxYwt#jt-j|���t2z����������}t9tjdtjdtj|i��}	d}
d}|jrV|�tj��}tA|d���\}}
|r!tC|d|
���}
|
|	tj<|r||	tj	<|	|||
fS)N�	websocket�z@No WebSocket UPGRADE hdr: {}
 Can "Upgrade" only to "WebSocket".)�text�upgradezNo CONNECTION upgrade hdr: {}c�P�g|]#}t|�������$Sr=)r<�strip)�.0�protos  r4�
<listcomp>z0WebSocketResponse._handshake.<locals>.<listcomp>�s8�������E�K�K�M�M�"�"���r6�,u8Client protocols %r don’t overlap server-known ones %r)�13�8�7zUnsupported version: �zHandshake error: FrT)�isserver)rEr��server_notakeover)"�headers�getr�UPGRADE�lowerr�r�format�
CONNECTION�SEC_WEBSOCKET_PROTOCOL�splitrLr�warning�SEC_WEBSOCKET_VERSION�SEC_WEBSOCKET_KEY�len�base64�	b64decode�binascii�Error�	b64encode�hashlib�sha1�encoder�digest�decoder	�SEC_WEBSOCKET_ACCEPTr_�SEC_WEBSOCKET_EXTENSIONSrr)r3rwr�r.�
req_protocolsr��version�key�
accept_val�response_headers�
notakeoverrE�
extensions�
enabledexts              r4�
_handshakezWebSocketResponse._handshake�sg���/���'�+�+�d�l�B�7�7�=�=�?�?�E�E�G�G�G�G� �5��&����T�\�2�2�3�3�	���
��G�K�K����<�<�B�B�D�D�D�D� �4�;�;��K�K���0�0������
����&�'�1�1���$�T�%@�A�G�G��L�L����M�
'�

�

���D�O�+�+�$�H��E�,�
�!�N�!��O�����+�+�d�8�"�=�=���*�*�*� �&G�g�&G�&G�H�H�H�H��k�k�$�0�1�1��	M��
G�#�f�.�s�3�3�4�4��:�:�$�*E�c�*E�*E�F�F�F�F�;���~�	M�	M�	M� �&A�#�&A�&A�B�B�B��L�	M�����%��L�������.�/�/�6�6�8�8�
�
�
�&�(�(�	�'���k�����)�:�
�
�
���
����>�		M� ���T�%B�C�C�J�$0�
�T�#J�#J�#J� �H�j��
M�'�%��
����
�CM� ��!>�?��	E�<D��T�8�9�����	
�	
s�:H�$H&c�:�|j|_|�|��\}}}}|�d��|j�|��|���||_|jj}|�J�t|j|||���}||fS)NrH)rEr�)
rTr��
set_statusr��update�force_closer_rjrrr)r3rwr�r.rEr�rrr~s        r4rzzWebSocketResponse._pre_start�s����]��
�26�/�/�'�2J�2J�/���8�Z������������G�$�$�$�������!����%�/�	��$�$�$� ���y�8�
�
�
�
�����r6r.r~c�>�||_||_|���|j}|�J�t	|jd|���|_|j�t|j|j
|j�����|j�d��dS)Ni)�loop�rEF)
rMrNrlrTrrjrOr.�
set_parserrr`r_�
keep_alive)r3rwr.r~r�s     r4r|zWebSocketResponse._post_starts���%�������������z������+�G�,=�u�4�P�P�P�����#�#��D�L�$�*<�t�~�V�V�V�	
�	
�	
�	��#�#�E�*�*�*�*�*r6c���|j�td���	|�|��\}}}}td|��S#t$rtdd��cYSwxYw)NzAlready startedTF)rN�RuntimeErrorr�r&r )r3rw�_r.s    r4�can_preparezWebSocketResponse.can_prepares}���<�#��0�1�1�1�	2� $���� 8� 8��A�x��A�"�$��1�1�1���	/�	/�	/�!�%��.�.�.�.�.�	/���s�A�A�Ac��|jSr1)rPr2s r4�closedzWebSocketResponse.closeds
���|�r6c��|jSr1)rSr2s r4�
close_codezWebSocketResponse.close_code#s����r6c��|jSr1)rMr2s r4�ws_protocolzWebSocketResponse.ws_protocol's��� � r6c��|jSr1)r_r2s r4rEzWebSocketResponse.compress+s
���~�r6�name�defaultc�Z�|j}|�|S|j}|�|S|�||��S)z}Get optional transport information.

        If no value associated with ``name`` is found, ``default`` is returned.
        )rNrr�get_extra_info)r3r�r�r~rrs     r4r�z WebSocketResponse.get_extra_info/s>��
����>��N��$�	����N��'�'��g�6�6�6r6c��|jSr1)rVr2s r4�	exceptionzWebSocketResponse.exception<s
����r6r6�messagec��vK�|j�td���|j�|���d{V��dS�N�Call .prepare() first)rNr�ro�r3r�s  r4rozWebSocketResponse.ping?sK�����<���6�7�7�7��l����(�(�(�(�(�(�(�(�(�(�(r6c��vK�|j�td���|j�|���d{V��dSr�)rNr��pongr�s  r4r�zWebSocketResponse.pongDsK�����<���6�7�7�7��l����(�(�(�(�(�(�(�(�(�(�(r6�datac���K�|j�td���t|t��st	dt|��z���|j�|d|����d{V��dS)Nr�zdata argument must be str (%r)F��binaryrE)rNr��
isinstancer<�	TypeError�type�send�r3r�rEs   r4�send_strzWebSocketResponse.send_strJs�����<���6�7�7�7��$��$�$�	K��<�t�D�z�z�I�J�J�J��l����U�X��F�F�F�F�F�F�F�F�F�F�Fr6c��K�|j�td���t|ttt
f��st
dt|��z���|j�|d|����d{V��dS)Nr�z#data argument must be byte-ish (%r)Tr�)	rNr�r��bytes�	bytearray�
memoryviewr�r�r�r�s   r4�
send_byteszWebSocketResponse.send_bytesQs������<���6�7�7�7��$��	�:� >�?�?�	P��A�D��J�J�N�O�O�O��l����T�H��E�E�E�E�E�E�E�E�E�E�Er6)�dumpsr�c��VK�|�||��|����d{V��dS)Nr�)r�)r3r�rEr�s    r4�	send_jsonzWebSocketResponse.send_jsonXs>�����m�m�E�E�$�K�K�(�m�;�;�;�;�;�;�;�;�;�;�;r6c��K�|jrdS|j�td���|����d{V��d|_dS)NzResponse has not been startedT)�	_eof_sentryr��closer2s r4�	write_eofzWebSocketResponse.write_eofasX�����>�	��F���'��>�?�?�?��j�j�l�l������������r6)�coder�r}r�r}c��K�|j�td���|���|j}|�J�|j�/|js(|�td��|j�d{V��|jrdSd|_	|j�||���d{V��|j	}|�J�|r|�
���d{V��nx#tjtj
f$r!|�tj���t"$r1}||_|�tj��Yd}~dSd}~wwxYw|jrdS|j}|�J�	t)j|j��4�d{V��|����d{V��}ddd���d{V��n#1�d{V��swxYwYnl#tj$r!|�tj���t"$r1}||_|�tj��Yd}~dSd}~wwxYw|jt2jkr|�|j��dS|�tj��tj
��|_dS)zClose websocket connection.Nr�rFT)rNr�rdrOrUrP�	feed_datarr�ryr}ru�CancelledErrorrvrsrrt�	ExceptionrVrQ�
async_timeoutr?rW�readr�r�CLOSEr�)r3r�r�r}�readerr~�exc�msgs        r4r�zWebSocketResponse.closejse�����<���6�7�7�7���� � � �����!�!�!��=�$�T�\�$����/��3�3�3��-���������<�	��5����	��,�$�$�T�7�3�3�3�3�3�3�3�3�3��)�F��%�%�%��
%��l�l�n�n�$�$�$�$�$�$�$����&��(<�=�	�	�	��*�*�;�+G�H�H�H���	�	�	�!�D�O��*�*�;�+G�H�H�H��4�4�4�4�4�����	����
�=�	��4�����!�!�!�		�$�,�T�]�;�;�
*�
*�
*�
*�
*�
*�
*�
*�"�K�K�M�M�)�)�)�)�)�)��
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*�
*����
*�
*�
*�
*����%�	�	�	��*�*�;�+G�H�H�H���	�	�	�!�D�O��*�*�;�+G�H�H�H��4�4�4�4�4�����	����
�8�y��&�&��*�*�3�8�4�4�4��4��&�&�{�'C�D�D�D�!�.�0�0����tsV�?AC�AD=�&D8�8D=�F3�4F!�F3�!
F+�+F3�.F+�/F3�38H�+&H�Hc�~�||_|j�,|jj�"|jj���dSdSdS)z+Set the close code and close the transport.N)rSrirrr�)r3r�s  r4rsz+WebSocketResponse._set_code_close_transport�sG������9� �T�Y�%8�%D��I��%�%�'�'�'�'�'�!� �%D�%Dr6c��K�|j�td���|j}|�J�	|j�td���|jr6|xjdz
c_|jtkrtd���tS|jrtS	|�
��|_	tj|p|j
��4�d{V��|j����d{V��}ddd���d{V��n#1�d{V��swxYwY|���|j}t!|d��d|_n##|j}t!|d��d|_wxYw�nP#t"jt"jf$r!|�t*j���t.$rIt*j|_|����d{V��t7t8jdd��cYSt<$rR}|j|_|�|j����d{V��t7t8j |d��cYd}~Sd}~wtB$r^}||_"d|_t*j|_|����d{V��t7t8j |d��cYd}~Sd}~wwxYw|j#t8j$kr>d|_|j%|_|js#|j&r|�d����d{V��ny|j#t8j'krd|_n\|j#t8j(kr)|j)r"|�*|j%���d{V����7|j#t8j+kr	|j)r��U|S)	Nr�Tz+Concurrent call to receive() is not allowedr
zWebSocket connection is closed.)r�F)r}),rOr�rTrUrPrRr(rrQr�
create_futurer�r?rXr�rlrrur�rvrsrrtr�OKrSr�rr�CLOSEDrr��ERRORr�rVr�r�r�rY�CLOSING�PINGrZr��PONG)r3r?r�r��waiterr�s      r4�receivezWebSocketResponse.receive�sL�����<���6�7�7�7��z������:	��}�(�"�#P�Q�Q�Q��|�
*����1�$����?�&?�?�?�&�'H�I�I�I�(�(���
*�)�)�
=� $� 2� 2� 4� 4��
�)�,�4�W�5U��@U�V�V�8�8�8�8�8�8�8�8�$(�L�$5�$5�$7�$7�7�7�7�7�7�7��8�8�8�8�8�8�8�8�8�8�8�8�8�8�8�8�8�8�8�8�8�8�8����8�8�8�8��)�)�+�+�+�!�]�F��v�t�,�,�,�$(�D�M�M��"�]�F��v�t�,�,�,�$(�D�M�(�(�(�(�M���*�G�,@�A�
�
�
��.�.�{�/K�L�L�L���
?�
?�
?�#.�>�� ��j�j�l�l�"�"�"�"�"�"�"� ��!1�4��>�>�>�>�>�!�
=�
=�
=�#&�8�� ��j�j�c�h�j�/�/�/�/�/�/�/�/�/� ���#�t�<�<�<�<�<�<�<�<������
=�
=�
=�"%��� $��
�#.�#?�� ��j�j�l�l�"�"�"�"�"�"�"� ���#�t�<�<�<�<�<�<�<�<�����
=�����x�9�?�*�*� $��
�#&�8�� ��|�2���2�
�*�*�5�*�1�1�1�1�1�1�1�1�1����Y�.�.�.� $��
�
���Y�^�+�+���+��i�i���)�)�)�)�)�)�)�)�)����Y�^�+�+���+���Jsu�E�!!D8� C4�"D8�4
C>�>D8�C>�D8�E�8 E�E�B
J*�)	J*�2AH?�9J*�?
J*�AJ%�J*�%J*�r?c���K�|�|���d{V��}|jtjkr-t	d�|j|j�����tt|j��S)Nz.Received message {}:{!r} is not WSMsgType.TEXT)	r�r�r�TEXTr�r�r�rr<�r3r?r�s   r4�receive_strzWebSocketResponse.receive_str�sz�����L�L��)�)�)�)�)�)�)�)���8�y�~�%�%��@�G�G��H�c�h�����
�
�C���"�"�"r6c���K�|�|���d{V��}|jtjkr t	d|j�d|j�d����t
t|j��S)NzReceived message �:z
 is not bytes)r�r�r�BINARYr�r�rr�rs   r4�
receive_byteszWebSocketResponse.receive_bytes�sq�����L�L��)�)�)�)�)�)�)�)���8�y�'�'�'��T���T�T�3�8�T�T�T�U�U�U��E�3�8�$�$�$r6)�loadsr?rc��TK�|�|����d{V��}||��S)Nr�)r)r3rr?r�s    r4�receive_jsonzWebSocketResponse.receive_json�s>�����%�%�g�%�6�6�6�6�6�6�6�6���u�T�{�{�r6c��$K�td���)Nz"Cannot call .write() for websocket)r�)r3r�s  r4�writezWebSocketResponse.writes�����?�@�@�@r6c��|Sr1r=r2s r4�	__aiter__zWebSocketResponse.__aiter__s���r6c��K�|����d{V��}|jtjtjtjfvrt�|Sr1)r�r�rr�r�r��StopAsyncIteration)r3r�s  r4�	__anext__zWebSocketResponse.__anext__	sL�����L�L�N�N�"�"�"�"�"�"���8�	���):�I�<L�M�M�M�$�$��
r6r�c�L�|j�|j�|��dSdSr1)rO�
set_exception)r3r�s  r4�_cancelzWebSocketResponse._cancels.���<�#��L�&�&�s�+�+�+�+�+�$�#r6)r/Nr1)r6)r/r%)<r7r8r9�
_length_check�floatrr:rr<�intrKrdrlrhrpr!rr{rr�rrzr|r&r��propertyr�r�r�rErr��
BaseExceptionr�r�ror�r�r��jsonr�rr�r�rr�r�rsrr�rrrrr
rrrr�
__classcell__)ras@r4r%r%:s���������M�
�+/���%)�#%��+�"*�"*�"*��"*�"�%��	"*�
�"*��
"*��E�?�"*��C�=�"*��"*��"*�
�"*�"*�"*�"*�"*�"*�H&�&�&�&���������&5�5�5�5�
�[�
�5I�
�
�
�
�
�
�S
�"�S
�	�!�3��d�2�	3�S
�S
�S
�S
�j �+� �%��_�8L�2M� � � � �"+�"�+�.1�+�;J�+�	
�+�+�+�+�"2�;�2�>�2�2�2�2��������X��� �H�S�M� � � ��X� ��!�X�c�]�!�!�!��X�!���$�����X��7�7�3�7��7��7�7�7�7��8�M�2�����)�)�%�)�$�)�)�)�)�
)�)�%�)�$�)�)�)�)�G�G�3�G�(�4�.�G�D�G�G�G�G�F�F�U�F�h�t�n�F�PT�F�F�F�F�$(�<�
"�Z�<�<�<��<��4�.�<�
�<�
�
<�<�<�<�����)�^�c�QU�9�9�9��9�6;�9�JN�9�	
�9�9�9�9�v(�k�(�d�(�(�(�(�@�@�X�e�_�@�	�@�@�@�@�D?C�#�#�#�H�U�O�#�s�#�#�#�#�AE�%�%�%�h�u�o�%��%�%�%�%�'+�j�T����#��;C�E�?��	�����A��A�$�A�A�A�A�����������,�=�,�T�,�,�,�,�,�,�,�,r6r%);rur�r�r�r�sys�typingrrrrrr�attr�	multidictr	r�r�abcr�helpersr
r�httprrrrrrrrrrr�logr�streamsrr�typedefsrr�web_exceptionsrr �web_requestr!�web_responser"�version_infor��__all__r(rr;�sr&r%r=r6r4�<module>r,s��������
�
�
�
�������������
�
�
�
�>�>�>�>�>�>�>�>�>�>�>�>�>�>�>�>�����!�!�!�!�!�!�������%�%�%�%�%�%�+�+�+�+�+�+�+�+���������������������������������4�4�4�4�4�4�4�4�.�.�.�.�.�.�.�.�9�9�9�9�9�9�9�9�$�$�$�$�$�$�(�(�(�(�(�(���w���#�#�#�#�#�������)*��5��:�)�)�)����T�$�d�3�3�3��������4�3��W,�W,�W,�W,�W,��W,�W,�W,�W,�W,r6

?>