Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
export.cpython-313.pyc74 linesDownload Raw Back to __pycache__
1�

2��j���v�%SSKrSSKrSSKJr SSKJr SSKrSSKrSSKJr SSKJ	r	 SSKJ3r4 SSKJr SSKJr SS	K
Jr SS5KJr S\R"S\R$4S
jrS\R$SS4SjrS\R"S\R*4SjrS\R$S\4SjrS\R"S\4SjrS\R"S\4SjrS\R"S\4SjrS\R"S\4SjrSS\R"S\4Sjjr\"\\\\\S9r \\\\R"/\\-44\!S'"SS5r"g)�N)�Callable)�Sequence)�command)�ctx)�6exceptions)�flow)�http)�assemble)�strutils�f�returnc���[USS5(d[R"S5e[U[R75(deURR5nURSS9 U$)N�requestz"Can't export flow with no request.F��strict)	�getattrr�CommandError�8isinstancer	�HTTPFlowr�copy�decode�rrs  �]D:\code\apps\devtools\python\user_packages\Python313\site-packages\mitmproxy/addons/export.py�cleanup_requestrs]���1�i��&�&��%�%�&J�K�K��a����'�'�'�'��i�i�n�n��G��N�N�%�N� ��N�rc�R�URRSS5 URRSS5UR:XaURRS5 URRSS5UR:XaURRS5 gg)z>Remove some headers that are redundant for curl/httpie export.zcontent-lengthN�host�z9:authority)�headers�pop�getr)rs r�pop_headersr"sz���O�O���(�$�/������6�2�&�'�,�,�6������F�#������<��,����<������L�)�=rc���[USS5(d[R"S5e[U[R105(deURR5nURSS9 U$)N�responsez#Can't export flow with no response.Fr)	rrrrr	rr$rr�rr$s  r�cleanup_responser&%s]���1�j�$�'�'��%�%�&K�L�L��a����'�'�'�'��z�z��� �H��O�O�5�O�!��Orc�^�URSS9nU(de[	S5Vs0sHn[U5SUS3_M snmSR
U4SjU55n[U4S	jU55(aS11[R"U5S3$[R"U5$![a [R"S5ef=fs snf)NTrz%Request content must be valid unicode� z\x�02xrc3�F># �UHnTRX5v� M g7f�N)r!)�.0�x�escape_control_charss  �r�	<genexpr>�.request_content_for_console.<locals>.<genexpr>7s ����H�4�a�/�3�3�A�9�9�4�s�!c3�,># �UH	oT;v� M g7fr+�)r,�charr.s  �rr/r08s����129�D�D�'�'�D�s�z13"$(printf z)")14�get_text�15ValueErrorrr�range�chr�join�any�shlex�quote)r�text�i�escaped_textr.s    @r�request_content_for_consoler?.s����O����t��,����t�16<A��9�E�9�a�C��F�c�!�C��M�1�9�E���7�7�H�4�H�H�L�17�189�D�199�9�9��E�K�K��5�6�b�9�9��;�;�|�$�$���O��%�%�&M�N�N�O��Fs�B+�C�+!Cc�X�[U5n[U5 S/nURR(aURRSOSn[R20R(aXU(aQURU:waAURSURSUS3nURS5 URU5 URRSS9H8upVUR5S	:XaURS215 M,USUSU3/-
nM: URS
:wa)UR(dUSS/-
nUSUR/-
nURUR5 SR!SU55nUR(aUS[#U53-
nU$)N�curlr�:z:[�]z	--resolveT��multizaccept-encodingz--compressedz-H�: �GETzcontent-length: 0z-X� c3�N# �UHn[R"U5v� M g7fr+�r:r;�r,�args  rr/�curl_command.<locals>.<genexpr>as���8�4�C�u�{�{�3�'�'�4���#%z -d )rr"�server_conn�peernamer�options�export_preserve_original_ip�pretty_host�port�appendr�items�lower�method�content�22pretty_urlr8r?)rr�args�server_addr�resolve�k�vrs        r�curl_commandr`?sn���a� �G�����8�D�/0�}�}�/E�/E�!�-�-�(�(��+�4�K�	���/�/�����;�.��(�(�)��7�<�<�.��;�-�q�I�����K� ����G�����%�%�D�%�1����7�7�9�)�)��K�K��'��T�a�S��1�#�;�'�'�D�	2��~�~������
�T�.�/�/�D���w�~�~�&�&���K�K��"�"�#��h�h�8�4�8�8�G�����T�5�g�>�?�@�@���Nrc�L�[U5n[U5 URnSURU/nURRSS9HupEUR
USU35 M SRSU55nUR(aUS[U5--
nU$)Nr	TrDrFrHc3�N# �UHn[R"U5v� M g7fr+rJrKs  rr/�!httpie_command.<locals>.<genexpr>ss���4�t��5�;�;�s�#�#�t�rNz <<< )23rr"rZrXrrVrUr8rYr?)rr�urlr[r^r_�cmds       r�httpie_commandrfgs����a� �G����24�25�26�C��G�N�N�C�(�D����%�%�D�%�1������q�c��A�3�K� �2�27
�(�(�4�t�4�284�C�����w�4�W�=�=�=���Jrc��[U5nURc[R"S5e[R29"U5$)NzRequest content missing.)r�raw_contentrrr30�assemble_requestrs  r�raw_requestrjys;���a� �G����"��%�%�&@�A�A��$�$�W�-�-rc��[U5nURc[R"S5e[R31"U5$)NzResponse content missing.)r&rhrrr32�assemble_responser%s  r�raw_responserm�s;����"�H����#��%�%�&A�B�B��%�%�h�/�/rc���[U[R5=(a+ UR=(a URRSLn[U[R5=(a+ UR33=(a UR34RSLnU(a�U(a�[
U5[U5/n[U[R5(a:UR(a)URURR55 URU5$U(a[
U5$U(a[U5$[R"S5e)zOReturn either the request or response if only one exists, otherwise return bothNz.Can't export flow with no request or response.)rr	rrrhr$rjrm�	websocketrU�_get_formatted_messagesr8rr)r�	separator�request_present�response_present�partss     r�rawru�s���	�1�d�m�m�$�X����X�q�y�y�7L�7L�TX�7X��	�1�d�m�m�$�	/�
�J�J�	/�
�J�J�"�"�$�.���+��Q���a��1���a����'�'�A�K�K��L�L����<�<�>�?��~�~�e�$�$�	��1�~��	��A����%�%�&V�W�Wr)rA�httpierurjrm�formatsc	��\rSrSrSr\R35"S5S\\4Sj5r\R36"S5S\S\	RS	\RRSS374Sj5r\R38"S5S\S
\	RSS394Sj5r\R40"S5S\S
\	RS\4Sj5rSrg41)�Export�c�4�URS[SS5 g)NrRFa[42            When exporting a request as an external command, make an effort to43            connect to the same IP as in the original request. This helps with44            reproducibility in cases where the behaviour depends on the45            particular host we are connecting to. Currently this only affects46            curl exports.47            )�48add_option�bool)�self�loaders  r�load�Export.load�s�����)���
�		49rzexport.formatsr
c�N�[[[R555$)z050Return a list of the supported export formats.51)�list�sortedrw�keys)r~s rrw�Export.formats�s��52�F�7�<�<�>�*�+�+rzexport.file�formatr�pathNc��U[;a[R"SU-5e[U"U5n[US5n[	U[535(aUR
U5 O!UR
URSS55 SSS5 g!,(df   g=f![a)n[R"[U55 SnAgSnAff=f)z54Export a flow to path.55�No such export format: %s�wbzutf-8�surrogateescapeN)rwrr�openr�bytes�write�encode�OSError�logging�error�str)r~r�rr�r_�fp�es       r�file�Export.file�s���56�� ��)�)�*E��*N�O�O��F�O�D�!��	"��d�D�!�R��a��'�'��H�H�Q�K��H�H�Q�X�X�g�/@�A�B�	"�!�!��57�	"��M�M�#�a�&�!�!��	"�s6�B#�A	B�	B#�58B �B#� B#�#59C�-C�Czexport.cliprc���URX5n[R"U5 g![Ra)n[R60"[
U55 SnAgSnAff=f)z(61Export a flow to the system clipboard.62N)�63export_str�	pyperclipr�PyperclipExceptionr�r�r�)r~r�rrYr�s     r�clip�Export.clip�sL��64�/�/�&�,��	"��N�N�7�#���+�+�	"��M�M�#�a�&�!�!��	"�s�*�A'�A"�"A'�exportc���U[;a[R"SU-5e[U"U5n[R"USS5n[R65"USS5nU$)z&66Export a flow and return the result.67r��utf8r��backslashreplace)rwrrr�always_bytes�68always_str)r~r�rrYs    rr��Export.export_str�sb��69�� ��)�)�*E��*N�O�O��&�/�!�$���'�'���9J�K���%�%�g�v�7I�J���rr2)�__name__�70__module__�__qualname__�__firstlineno__r�rrr�rwr�Flow�	mitmproxy�types�Pathr�r�r��__static_attributes__r2rrryry�s���71�
�_�_�%�&�,��#��,�'�,�
�_�_�]�#�"�3�"�d�i�i�"�y���7K�7K�"�PT�"�$�"� 
�_�_�]�#�"�3�"�4�9�9�"��"�$�"�
�_�_�X��
��
����
�s�
��
rry)s
72
73)#r�r:�collections.abcrrr��mitmproxy.typesr�rrrrr	�mitmproxy.net.http.http1r74�mitmproxy.utilsrr��Requestrr"�Responser&r�r?r`rfr�rjrmru�dictrw�__annotations__ryr2rr�<module>r�sS����$�$����� ���-�$��t�y�y��T�\�\��*����*�$�*���	�	��d�m�m��%����%�#�%�"%�D�I�I�%�#�%�P�d�i�i��C��$.�4�9�9�.��.�0�D�I�I�0�%�0�X�4�9�9�X��X�0:>�	�����:���c�8�T�Y�Y�K��u��4�5�5�	6��@�@r
codekingpro/portable-devtools · Team Ai