Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
websocket.cpython-313.pyc72 linesDownload Raw Back to __pycache__
1�

2��j����SrSSKrSSKrSSKJr SSKJr SSKJr SSKJ	r	 \3\\\
\\\4r"SS\	R 5r\"S	S4\	R$55rg)aq5Mitmproxy used to have its own WebSocketFlow type until mitmproxy 6, but now WebSocket connections now are represented6as HTTP flows as well. They can be distinguished from regular HTTP requests by having the7`mitmproxy.http.HTTPFlow.websocket` attribute set.8 9This module only defines the classes for individual `WebSocketMessage`s and the `WebSocketData` container.10�N)�	dataclass)�field)�Opcode)�serializablec�V�\rSrSr%Sr\\S'\\S'\\S'\	\S'\\S'\\S'SS\11\-S\S\S\	S	-S\S\S12S	4Sjjr\S\
4S
j5rS13\
4SjrS\
S14S	4SjrS15\4SjrSr\S16\4Sj5rSrSr\S17\4Sj5r\R2S\S18S	4Sj5rSrg	)�WebSocketMessage�a�19A single WebSocket message sent from one peer to the other.20 21Fragmented WebSocket messages are reassembled by mitmproxy and then22represented as a single instance of this class.23 24The [WebSocket RFC](https://tools.ietf.org/html/rfc6455) specifies both25text and binary messages. To avoid a whole class of nasty type confusion bugs,26mitmproxy stores all message contents as `bytes`. If you need a `str`, you can access the `text` property27on text messages:28 29>>> if message.is_text:30>>>     text = message.text31�from_client�type�content�	timestamp�dropped�injectedN�returnc��X l[U5UlX0lU=(d [R"5UlXPlX`lg�N)r32rrr�timer
rr)�selfrr33rr
rrs       �YD:\code\apps\devtools\python\user_packages\Python313\site-packages\mitmproxy/websocket.py�__init__�WebSocketMessage.__init__6s6��'���4�L��	��� )� 8�T�Y�Y�[����� �
��statec��U"U6$r�)�clsrs  r�34from_state�WebSocketMessage.from_stateFs���E�{�rc��[UR5URURURUR35UR4$r)�intrr36rr
rr�rs r�	get_state�WebSocketMessage.get_stateJs<����	�	�N�����L�L��N�N��L�L��M�M�
37�	38rc�h�UunUlUlUlUlUl[U5Ulgr)r39rr
rrrr)rr�typs   r�	set_state�WebSocketMessage.set_stateTs4��
�	40�����L��N��L��M��3�K��	rc�`�UR(aSUR-$SUR-$)Ns[OUTGOING] s[INCOMING] )r41rr!s r�_format_ws_message�#WebSocketMessage._format_ws_message_s)�����!�D�L�L�0�0�!�D�L�L�0�0rc��UR[R:Xa"[URRSS95$[UR5$)N�replace)�errors)rr�TEXT�reprr�decoder!s r�__repr__�WebSocketMessage.__repr__es>���9�9����#�����+�+�9�+�=�>�>�����%�%rc�<�UR[R:H$)zt42`True` if this message is assembled from WebSocket `TEXT` frames,43`False` if it is assembled from `BINARY` frames.44)rrr.r!s r�is_text�WebSocketMessage.is_textks���y�y�F�K�K�'�'rc��SUlg)z;Drop this message, i.e. don't forward it to the other peer.TN)rr!s r�drop�WebSocketMessage.dropss	����rc�X�[R"S[SS9 UR5 g)z!A deprecated alias for `.drop()`.z;WebSocketMessage.kill() is deprecated, use .drop() instead.�)�45stacklevelN)�warnings�warn�DeprecationWarningr7r!s r�kill�WebSocketMessage.killws"���
�
�I���	46�47	
�	�	�rc���UR[R:wa0[URRR5S35eURR5$)z�48The message content as text.49 50This attribute is only available if `WebSocketMessage.is_text` is `True`.51 52*See also:* `WebSocketMessage.content`53�1 WebSocket frames do not have a 'text' attribute.)rrr.�AttributeError�name�titlerr0r!s r�text�WebSocketMessage.text�sS���9�9����#� ��9�9�>�>�'�'�)�*�*[�\��
��|�|�"�"�$�$r�valuec���UR[R:wa0[URRR5S35eUR
5Ulg)NrB)rrr.rCrDrE�encoder)rrHs  rrFrG�sK���9�9����#� ��9�9�>�>�'�'�)�*�*[�\��
��|�|�~��r)rrr54rr
r)NFF)�__name__�55__module__�__qualname__�__firstlineno__�__doc__�bool�__annotations__r�bytes�floatr r�classmethod�WebSocketMessageStaterr"r&r)r1�propertyr4r7r?�strrF�setter�__static_attributes__rrrrrsO��
���7�56�L��57�N�A���A�
�M�S��N�f�#'���!��F�l�!��!��	!�58�4�<�!��
!��!�59�!� ��4����60�0�61�	 �4�	 ��	 �1�E�1�&��(��(��(����
%�c�
%��
%�62�[�[�&�#�&�$�&��&rrc��\rSrSr%Sr\"\S9r\\\	S'Sr63\S-\	S'Sr\
S-\	S'Sr\S-\	S'Sr\S-\	S	'S64rS\4SjrS
rg)�
WebSocketData�z�65A data container for everything related to a single WebSocket connection.66This is typically accessed as `mitmproxy.http.HTTPFlow.websocket`.67)�default_factory�messagesN�closed_by_client�68close_code�close_reason�
timestamp_endc�4�S[UR5S3$)Nz<WebSocketData (z messages)>)�lenr^r!s rr1�WebSocketData.__repr__�s��!�#�d�m�m�"4�!5�[�A�Arrc�F�SRSUR55$)N�69c3�@# �UHoR5v� M g7fr)r))�.0�ms  r�	<genexpr>�8WebSocketData._get_formatted_messages.<locals>.<genexpr>�s���H�-�Q�.�.�0�0�-�s�)�joinr^r!s r�_get_formatted_messages�%WebSocketData._get_formatted_messages�s���z�z�H�$�-�-�H�H�Hrr)rKrLrMrNrOr�listr^rrQr_rPr`r rarWrbrSr1rRrnrYrrrr[r[�s~���70(-�T�'B�H�d�#�$�B�C�$(��d�T�k�(��71"�J��d�72�!�I�#�L�#��*�#�K�"&�M�5�4�<�&�3�B�I��Irr[)rOrr<�dataclassesrr�wsproto.frame_protocolr�mitmproxy.coretypesr�tupler rPrRrSrU�Serializabler�SerializableDataclassr[rrr�<module>rwso�����!��)�,��c�4���t�T�A�B��B&�|�0�0�B&�J�I�L�6�6�I��Ir
codekingpro/portable-devtools · Team Ai