Team Ai
Datasetpublic

codekingpro/portable-devtools

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

2��j�����SSKrSSKrSSKrSSKrSSKrSSKrSSKJr SSKJ	r	 SSKJ3r4 SSKJr SSKJr SSK
Jr SSK
Jr SS	KJr SS5KJr SSKJr SSKJr SS
KJr SSKJr SSKJr SSKJr SSKJr SSKJr SSKJ r  SSKJ!r! SSKJ"r" SSK#J$r$ SSK#J%r% SSK#J&r& SSK'J(r( SSK'J)r) SSK'J*r* SSK+J,r, SSK+J-r- SSK.J/r/ S\0S \14S!jr2S\1\0-S \04S"jr3"S#S$\Rh5r5\"S%S&\Rl55r7\"S'S(\755r8\"S)S*\755r9"S+S,\Rl5r:"S-S.\:5r;"S/S0\:5r<"S1S2\Rz5r>/S3Qr?g)4�N)�Callable)�Iterable)�Iterator)�Mapping)�Sequence)�	dataclass)�fields)�6formatdate)�	mktime_tz)�parsedate_tz)�Any)�cast��flow)�	multidict)�serializable)�encoding)�cookies)�	multipart)�status_codes)�url)�assemble_content_type)�infer_content_encoding)�parse_content_type)�human)�strutils)�	typecheck��always_bytes)�7always_str)�
WebSocketData�x�returnc�&�URSS5$�N�utf-8�surrogateescape)�decode�r"s �TD:\code\apps\devtools\python\user_packages\Python313\site-packages\mitmproxy/http.py�_nativer+(s���8�8�G�.�/�/�c�2�[R"USS5$r%)rrr)s r*�
_always_bytesr.,s��� � ��G�->�?�?r,c�d^�\rSrSr%SrSS\\\\44U4Sjjjr\\\\4S4\	S'\8S\4Sj5r\9S\4S	j5r
S\4S10jrS\\-SS4U4S
jjrS\\4U4SjjrS\\-S\\4U4SjjrS\\-S\\\-4U4SjjrS\S\\-S\\-4U4SjjrSU4SjjrSrU=r$)�Headers�1a�11Header class which allows both convenient access to individual headers as well as12direct access to the underlying raw data. Provides a full dictionary interface.13 14Create headers with keyword arguments:15>>> h = Headers(host="example.com", content_type="application/xml")16 17Headers mostly behave like a normal dict:18>>> h["Host"]19"example.com"20 21Headers are case insensitive:22>>> h["host"]23"example.com"24 25Headers can also be created from a list of raw (header_name, header_value) byte tuples:26>>> h = Headers([27    (b"Host",b"example.com"),28    (b"Accept",b"text/html"),29    (b"accept",b"application/xml")30])31 32Multiple headers are folded into a single header as per RFC 7230:33>>> h["Accept"]34"text/html, application/xml"35 36Setting a header removes all existing headers with the same name:37>>> h["Accept"] = "application/text"38>>> h["Accept"]39"application/text"40 41`bytes(h)` returns an HTTP/1 header block:42>>> print(bytes(h))43Host: example.com44Accept: application/text45 46For full control, the raw header fields can be accessed:47>>> h.fields48 49Caveats:50 - For use with the "Set-Cookie" and "Cookie" headers, either use `Response.cookies` or see `Headers.get_all`.51�r	c52�r>�[TU]U5 URH:up4[U[5(a[U[5(aM1[S5e UR
UR5VVs0sH*upT[U5RSS5[U5_M, snn5 gs snnf)a�53*Args:*54 - *fields:* (optional) list of ``(name, value)`` header byte tuples,55   e.g. ``[(b"Host", b"example.com")]``. All names and values must be bytes.56 - *\*\*headers:* Additional headers to set. Will overwrite existing values from `fields`.57   For convenience, underscores in header names will be transformed to dashes -58   this behaviour does not extend to other methods.59 60If ``**headers`` contains multiple keys that have equal ``.lower()`` representations,61the behavior is undefined.62zHeader fields must be bytes.�_�-N)63�super�__init__r	�64isinstance�bytes�	TypeError�update�itemsr.�replace)�selfr	�headers�key�value�name�	__class__s      �r*r7�Headers.__init__]s����	���� ��+�+�J�C��c�5�)�)��E�5�1I�1I�� >�?�?�&�65	
���$+�=�=�?�
�#2�K�D��d�#�+�+�D�$�7��u�9M�M�#2�
�	66��
s�91B367.r#c�$�SRU5$)N�, ��join)�valuess r*�_reduce_values�Headers._reduce_valuesys���y�y�� � r,c�"�UR5$�N)�lower)r@s r*�_kconv�Headers._kconv~s���y�y�{�r,c�p�UR(a%SRSUR55S-$g)Ns
68c3�D# �UHnSRU5v� M g7f)s: NrG)�.0�fields  r*�	<genexpr>�$Headers.__bytes__.<locals>.<genexpr>�s���K�{�e��69�70�5� 1� 1�{�s� r,)r	rH�r>s r*�	__bytes__�Headers.__bytes__�s*���;�;��<�<�K�t�{�{�K�K�g�U�U�r,r@Nc�:>�[U5n[TU]	U5 grM)r.r6�__delitem__)r>r@rCs  �r*r[�Headers.__delitem__�s����C� ��
���C� r,c#�R># �[TU]5Hn[U5v� M g7frM)r6�__iter__r+)r>r"rCs  �r*r^�Headers.__iter__�s"������!�#�A��!�*��$�s�$'rBc�v>�[U5n[TU]	U5Vs/sHn[U5PM sn$s snf)aa71Like `Headers.get`, but does not fold multiple headers into a single one.72This is useful for Set-Cookie and Cookie headers, which do not support folding.73 74*See also:*75 - <https://tools.ietf.org/html/rfc7230#section-3.2.2>76 - <https://datatracker.ietf.org/doc/html/rfc6265#section-5.4>77 - <https://datatracker.ietf.org/doc/html/rfc7540#section-8.1.2.5>78)r.r6�get_allr+)r>rBr"rCs   �r*ra�Headers.get_all�s6����T�"��$)�G�O�D�$9�:�$9�q���79�$9�:�:��:s�6rIc�x>�[U5nUVs/sHn[U5PM nn[TU]	X5$s snf)zK80Explicitly set multiple headers for the given key.81See `Headers.get_all`.82)r.r6�set_all)r>rBrIr"rCs    �r*rd�Headers.set_all�s<���83�T�"��,2�3�F�q�-��"�F��3��w��t�,�,��4s�7�indexrAc�R>�[U5n[U5n[TU]	XU5 grM)r.r6�insert)r>rfr@rArCs    �r*rh�Headers.insert�s%����C� ���e�$��
���u�5�)r,c�T>�U(aSUR5$[TU]	5$)Nc3�R# �UHup[U5[U54v� M g7frM)r+�rS�k�vs   r*rU� Headers.items.<locals>.<genexpr>�s���E����W�Q�Z����,��s�%')r	r6r<)r>�multirCs  �r*r<�
Headers.items�s!����E����E�E��7�=�?�"r,)r2)F)�__name__�84__module__�__qualname__�__firstlineno__�__doc__r�tupler9r7�__annotations__�staticmethod�strrJrOrXr[rr^�listrard�intrhr<�__static_attributes__�
__classcell__�rCs@r*r0r01s���)�V85�x��e�U�l�(;�<�86�87�4
�%��u��%�s�*�+�+��!�#�!��!���s�����5��!�s�U�{�!�t�!��(�3�-��;�C�%�K�;�D��I�;�-�C�%�K�-��#��+�1F�-�*�C�*�c�E�k�*�#��+�*�88#�#r,r0c��\rSrSr%\\S'\\S'\S-\S'\S-\S'\\S'\S-\S'S	rS89r	Sr90\S5rS
r
g)�MessageData��http_versionr?N�content�trailers�timestamp_start�
timestamp_endc��[U5HCn[XR5n[R"URX!R915 ME grM)r	�getattrrBr�check_option_type�type)r>rT�vals   r*�
__post_init__�MessageData.__post_init__�s6�������d�J�J�/���+�+�E�J�J��Z�Z�H�&r,c��UR5H/up#US;aUb[RU5n[XU5 M1 g)N)r?r�)r<r0�92from_state�setattr)r>�statermrns    r*�	set_state�MessageData.set_state�s;���K�K�M�D�A��+�+��
��&�&�q�)���D�Q��"r,c��[U5R5nUSR5US'USbUSR5US'U$)Nr?r�)�vars�copy�	get_state�r>r�s  r*r��MessageData.get_state�sR���T�93���!�� ��+�5�5�7��i�����(� %�j� 1� ;� ;� =�E�*���r,c��[RUS5US'USbUS5US'U"S0UD6$)Nr?r�r2)r0r���clsr�s  r*r��MessageData.from_state�sM��"�-�-�e�I�.>�?��i�����(� '� 2� 2�5��3D� E�E�*���|�U�|�r,r2)rrrsrtrur9rxr0�floatr�r�r��classmethodr�r}r2r,r*r�r��s[����
��
�T�\����n�����4�<���	I�94 �����r,r�c�R�\rSrSr%\\S'\\S'\\S'\\S'\\S'\\S'Srg	)95�RequestData���host�port�method�scheme�	authority�pathr2N)	rrrsrtrurzrxr|r9r}r2r,r*r�r��s!��96
�I�97
�I��M��M���98�Kr,r�c�*�\rSrSr%\\S'\\S'Srg)�ResponseData���status_code�reasonr2N)rrrsrtrur|rxr9r}r2r,r*r�r��s
�����Mr,r�c���\rSrSr%Sr\S5rSrSr\	\99S'Sr\\
/\\
\
-4\-\100S'\S	\4S101j5r\R&S\\
-S	S4S
j5r\S	\4Sj5r\S	\4Sj5r\S	\4Sj5r\S	\4Sj5r\S	\4Sj5r\R&S\S	S4Sj5r\S	\S-4Sj5r\R&S\S-S	S4Sj5r\S	\
S-4Sj5r\R&S\
S-S	S4Sj5r\S	\
S-4Sj5r\R&S\
S-S	S4Sj5r\S	\S-4Sj5r\R&S\S-S	S4Sj5rS\
S-S	S4SjrS1S \S	\
S-4S!jjrS"\S-S	S4S#jr S1S \S	\S-4S$jjr!\S	\"4S%j5r#\#R&S&\"S	S4S'j5r#\S	\"S-4S(j5r$\$R&S)\"S-4S*j5r$S1S \S	S4S+jjr%S,\S	S4S-jr&S.\'S	\'4S/jr(S0r)g)2�Message��z(Base class for `Request` and `Response`.c��U"S0UD6$)Nr2r2r�s  r*r��Message.from_state�s���|�U�|�r,c�6�URR5$rM)�datar�rWs r*r��Message.get_state�s���y�y�"�"�$�$r,c�:�URRU5 grM)r�r�r�s  r*r��Message.set_state�s���	�	���E�"r,r�F�streamr#c�N�URRRSS5$)z.102HTTP version string, for example `HTTP/1.1`.103r&r')r�r�r(rWs r*r��Message.http_versions"��104�y�y�%�%�,�,�W�6G�H�Hr,r�Nc�R�[R"USS5URlgr%)rrr�r�)r>r�s  r*r�r�
s!��!)�!6�!6��'�#4�"105��	�	�r,c�4�URRS:H$)NsHTTP/1.0�r�r�rWs r*�	is_http10�Message.is_http10����y�y�%�%��4�4r,c�4�URRS:H$)N�HTTP/1.1r�rWs r*�	is_http11�Message.is_http11r�r,c�4�URRS:H$)NsHTTP/2.0r�rWs r*�is_http2�Message.is_http2r�r,c�4�URRS:H$)NsHTTP/3r�rWs r*�is_http3�Message.is_http3s���y�y�%�%��2�2r,c�.�URR$)z106The HTTP headers.107�r�r?rWs r*r?�Message.headers#s��108�y�y� � � r,�hc�$�XRlgrMr��r>r�s  r*r?r�*s���	�	�r,c�.�URR$)zY109The [HTTP trailers](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Trailer).110�r�r�rWs r*r��Message.trailers.s��111�y�y�!�!�!r,c�$�XRlgrMr�r�s  r*r�r�5s���	�	�r,c�.�URR$)an112The raw (potentially compressed) HTTP message body.113 114In contrast to `Message.content` and `Message.text`, accessing this property never raises.115`raw_content` may be `None` if the content is missing, for example due to body streaming116(see `Message.stream`). In contrast, `b""` signals a present but empty message body.117 118*See also:* `Message.content`, `Message.text`119�r�r�rWs r*�raw_content�Message.raw_content9s���y�y� � � r,r�c�$�XRlgrMr�)r>r�s  r*r�r�Fs��#�	�	�r,c�"�UR5$)z�120The uncompressed HTTP message body as bytes.121 122Accessing this attribute may raise a `ValueError` when the HTTP content-encoding is invalid.123 124*See also:* `Message.raw_content`, `Message.text`125)�get_contentrWs r*r��Message.contentJs�����!�!r,rAc�&�URU5 grM)�set_content�r>rAs  r*r�r�Us������r,c�"�UR5$)z�126The uncompressed and decoded HTTP message body as text.127 128Accessing this attribute may raise a `ValueError` when either content-encoding or charset is invalid.129 130*See also:* `Message.raw_content`, `Message.content`131)�get_textrWs r*�text�Message.textYs���}�}��r,c�&�URU5 grM)�set_textr�s  r*r�r�ds���
�
�e�r,c���UcSUlg[U[5(d"[S[	U5R132S35eURRS5n[R"X=(d S5UlSUR;ag[[UR55URS'g![a URS	XlN\f=f)Nz#Message content must be bytes, not z/. Please use .text if you want to assign a str.�content-encoding�identityztransfer-encodingzcontent-length)
r�r8r9r:r�rrr?�getr�encode�133ValueErrorrz�len)r>rA�ces   r*r��Message.set_contenths����=�#�D����%��'�'��5�d�5�k�6J�6J�5K�L@�@��
��\�\�
�
�0�
1��	%�'���u�6F�J�G�D���$�,�,�.�
�-0��T�5E�5E�1F�-G�D�L�L�)�*���	%����/�0�$��		%�s�$C�C �C �strictc�P�URcgURRS5nU(aG[R"URU5n[U[5(a[SU35eU$UR$![a U(aeURs$f=f)z�134Similar to `Message.content`, but does not raise if `strict` is `False`.135Instead, the compressed message body is returned as-is.136Nr�zInvalid Content-Encoding: )r�r?r�rr(r8rzr�)r>r�r�r�s    r*r��Message.get_content�s���137���#��
�\�\�
�
�0�
1��
�	
(�"�/�/�$�*:�*:�B�?���g�s�+�+�$�'A�"��%F�G�G����#�#�#���
(����'�'�'�
(�s�AB�B%�$B%r�c��UcSUlg[URRSS55n[	[138[R"X55Ulg![aj [URRSS55=(d SS04nSUSS'[U6URS'SnURUS	5Ulgf=f)139N�content-type�r��plainr&��charset�utf8r')r�rr?r�rr9rr�r�rr)r>r��enc�cts    r*r��Message.set_text�s����<��D�L��$�T�\�\�%5�%5�n�b�%I�J��	?���x���t�'A�B�D�L���140	?�#�D�L�L�$4�$4�^�R�$H�I�����N�B�141 '�B�q�E�)��+@�"�+E�D�L�L��(��C��;�;�s�,=�>�D�L�142	?�s�)A�A1C�Cc��URU5nUcg[URRSS5U5n[	[143[R"X#55$![a U(aeURSS5s$f=f)z�144Similar to `Message.text`, but does not raise if `strict` is `False`.145Instead, the message body is returned as surrogate-escaped UTF-8.146Nr�r�r�r')	r�rr?r�rrzrr(r�)r>r�r�r�s    r*r��Message.get_text�s{��147�"�"�6�*���?��$�T�\�\�%5�%5�n�b�%I�7�S��	=���X�_�_�W�:�;�;���	=����>�>�&�*;�<�<�	=�s�#A!�!$B�Bc�.�URR$)z 148*Timestamp:* Headers received.149�r�r�rWs r*r��Message.timestamp_start�s��150�y�y�(�(�(r,r�c�$�XRlgrMr)r>r�s  r*r�r�s��$3�	�	�!r,c�.�URR$)z"151*Timestamp:* Last byte received.152�r�r�rWs r*r��Message.timestamp_end�s��153�y�y�&�&�&r,r�c�$�XRlgrMr)r>r�s  r*r�r�s��"/�	�	�r,c��UR(dgURU5nURRSS5 X lg)z�154Decodes body based on the current Content-Encoding header, then155removes the header.156 157If the message body is missing or empty, no action is taken.158 159*Raises:*160 - `ValueError`, when the content-encoding is invalid and strict is True.161Nr�)r�r�r?�popr�)r>r��decodeds   r*r(�Message.decode�s<�����
��"�"�6�*�������+�T�2��r,rc��XRS'URUlSUR;a[SU<35eg)a162Encodes body with the given encoding, where e is "gzip", "deflate", "identity", "br", or "zstd".163Any existing content-encodings are overwritten, the content is not decoded beforehand.164 165*Raises:*166 - `ValueError`, when the specified content-encoding is invalid.167r�zInvalid content encoding N)r?r�r�r�)r>rs  r*r��Message.encode�sB��,4���'�(��'�'����T�\�\�1��8���E�F�F�2r,�kwargsc�j�URSS9nUc[S5e[R"U40UD6$)a~168Returns the JSON encoded content of the response, if any.169`**kwargs` are optional arguments that will be170passed to `json.loads()`.171 172Will raise if the content can not be decoded and then parsed as JSON.173 174*Raises:*175 - `json.decoder.JSONDecodeError` if content is not valid JSON.176 - `TypeError` if the content is not available, for example because the response177    has been streamed.178F�r�z!Message content is not available.)r�r:�json�loads)r>r
r�s   r*r�Message.json�s<���"�"�%�"�0���?��?�@�@��:�:�g�0��0�0r,)r�r�)T)*rrrsrtrurvr�r�r�r�r�rxr�rr9r�bool�propertyrzr��setterr�r�r�r�r0r?r�r�r�r�r�r�r�r�r�r�r�r(r�r
rr}r2r,r*r�r��s���2�����%�#���@E�F�H�e�W�h�u�o��5�5�6��=�E���I�c�I��I����179��u��180��181��182�183�5�4�5��5��5�4�5��5��5�$�5��5��3�$�3��3��!��!��!�
�^�^����T�����"�'�D�.�"��"��_�_��'�D�.��T�����184!�U�T�\�185!��186!����$�5�4�<�$�D�$��$��"����"��"�
�^�^� �U�T�\� �d� �� ���c�D�j����187�[�[��#��*������H����H�$�H�2$�$�$�%�$�,�$�,?�S�4�Z�?�D�?�(=�t�=�s�T�z�=� �)��)��)����4�u�4��4��4��'�u�t�|�'��'����0�5�4�<�0��0��T��T��$G�s�G�t�G�1�S�1�S�1r,r�c�X�\rSrSr%Sr\\S'S\S\S\	S\	S\	S	\	S188\	S\189\\\	\	4S4-S
\	S-S\190\\\	\	4S4-S-S\S\S-4Sjr
S\4Sjr\SES\S\S
\	\-S\191\\\	-\\	-4-\\\	\	4-SS4192Sjj5r\S\4Sj5r\S\4Sj5r\R,S\\	-SS4Sj5r\S\4Sj5r\R,S\\	-SS4Sj5r\S\4Sj5r\R,S\\	-SS4Sj5r\S\4Sj5r\R,S\\	-SS4S j5r\S\S-4S!j5r\R,SS\-\	-SS4S"j5r\S\4S#j5r\R,S\SS4S$j5rSFS%jr\S\4S&j5r\R,S\\	-SS4S'j5r\S\4S(j5r\R,S\\	-SS4S)j5r\S\4S*j5r\S\4S+j5r S,r!S-r"\S\#RH\\44S.j5r%\%R,S/5r%S0r&S1r'\S\#RH\\44S2j5r(\(R,S35r(\S\\S44S4j5r)\)R,S5\\4S6j5r)SFS7jr*SFS8jr+SFS9jr,S:r-S;\.\\\4SS4S<jr/\S\#RH\\44S=j5r0\0R,S>5r0S\1\\	\	44S?jr2S@\1\\	\	4SS4SAjr3\S\#RH\	\	44SBj5r4\4R,S@\1\\	\	4SS4SCj5r4SDr5g)G�Requestiz193An HTTP request.194r�r�r�r�r�r�r�r�r?.r�Nr�r�r�c
���[U[5(aURSS5n[U[5(aUR	SS5n[U[5(aUR	SS5n[U[5(aUR	SS5n[U[5(aUR	SS5n[U[5(aUR	SS5n[U	[5(a![S[
U	5R35e[U[5(d[U5nU195b [U196[5(d[U1975n198[UUUUUUUUU	U199UUS9Ul200g)N�idnar��ascii�Content must be bytes, not )r�r�r�r�r�r�r�r?r�r�r�r�)r8r9r(rzr�r�r�rrr0r�r�)
r>r�r�r�r�r�r�r�r?r�r�r�r�s
             r*r7�Request.__init__sD�� �d�E�"�"��;�;�v�x�0�D��f�c�"�"��]�]�7�H�5�F��f�c�"�"��]�]�7�H�5�F��i��%�%�!�(�(��(�;�I��d�C� � ��;�;�w��1�D��l�C�(�(�'�.�.�w��A�L��g�s�#�#��:�4��=�;Q�;Q�:R�S�T�T��'�7�+�+��g�&�G���201�8�W�(E�(E��x�(�H��������%����+�'�
202��	r,r#c���UR(a-UR(aURSUR3nOSnUR=(d SnSURSUUS3$)N�:r�zRequest(� �))r�r�r�r�)r>�hostportr�s   r*�__repr__�Request.__repr__>sV���9�9�����)�)��A�d�i�i�[�1�H��H��y�y��B���$�+�+��a��z�$��q�9�9r,rc��[U[5(aO�[U[5(a![SUR555nON[U[5(a[U5nO-[SR
[U5R55eU"SSURSS5SSSSUSS	[R"5[R"55nX%l[U[5(aX5l
U$[U[5(aX5lU$[S203[U5RS35e)z.204Simplified API for creating request objects.205c3�Z# �UH!up[USS5[USS54v� M# g7f�r&r'Nrrls   r*rU�Request.make.<locals>.<genexpr>W�9����206,�D�A�!��G�->�?� ��G�->�?��,���)+�6Expected headers to be an iterable or dict, but is {}.r�rr&r'r,r�N�,Expected content to be str or bytes, but is �.)r8r0�dictr<rr:�formatr�rrr��timerr9r�rzr�)r�r�rr�r?�reqs      r*�make�Request.makeFs+���g�w�'�'��
���
&�
&���207$�M�M�O���G����
*�
*��g�&�G��H�O�O���M�*�*���
���
��M�M�'�#4�5���������I�I�K��I�I�K�
208�����g�u�%�%�!�K��209����
%�
%��H��210�	�>�t�G�}�?U�?U�>V�VW�X��
r,c�J�URS:XagUR(agg)z�211*Read-only:* HTTP request form as defined in [RFC 7230](https://tools.ietf.org/html/rfc7230#section-5.3).212 213origin-form and asterisk-form are subsumed as "relative".214�CONNECTr��absolute�relative)r�r�rWs r*�first_line_format�Request.first_line_format�s ���;�;�)�#��
�^�^��r,c�j�URRRSS5R5$)z"215HTTP request method, e.g. "GET".216r&r')r�r�r(�upperrWs r*r��Request.method�s+��217�y�y���&�&�w�0A�B�H�H�J�Jr,r�c�<�[USS5URlgr%)rr�r��r>r�s  r*r�r;����'��W�6G�H��	�	�r,c�N�URRRSS5$)z9218HTTP request scheme, which should be "http" or "https".219r&r')r�r�r(rWs r*r��Request.scheme�s"��220�y�y���&�&�w�0A�B�Br,c�<�[USS5URlgr%)rr�r�r=s  r*r�r@�r>r,c��URRRS5$![a) URRRSS5s$f=f)aY221HTTP request authority.222 223For HTTP/1, this is the authority portion of the request target224(in either absolute-form or authority-form).225For origin-form and asterisk-form requests, this property is set to an empty string.226 227For HTTP/2, this is the :authority pseudo header.228 229*See also:* `Request.host`, `Request.host_header`, `Request.pretty_host`230rr�r')r�r�r(�UnicodeErrorrWs r*r��Request.authority�sR��	I��9�9�&�&�-�-�f�5�5���	I��9�9�&�&�-�-�f�6G�H�H�	I�s�$'�0A�Ac��[U[5(aURSS5nXRlg![a URSS5nN/f=f)Nrr�r�r')r8rzr�rCr�r�r=s  r*r�rD�sR���c�3���
<��j�j���2��"�	�	��� �
<��j�j��):�;��
<�s�:�A�Ac�.�URR$)az231Target server for this request. This may be parsed from the raw request232(e.g. from a ``GET http://example.com/ HTTP/1.1`` request line)233or inferred from the proxy mode (e.g. an IP in transparent mode).234 235Setting the host attribute also updates the host header and authority information, if present.236 237*See also:* `Request.authority`, `Request.host_header`, `Request.pretty_host`238)r�r�rWs r*r��Request.host�s���y�y�~�~�r,c�\�[USS5URlUR5 g)Nrr�)r r�r��_update_host_and_authorityr=s  r*r�rG�s"��#�C���:��	�	���'�'�)r,c��UR(dUR(a9UR=(d& URRRSS5$URRRSS5$)z�239The request's host/authority header.240 241This property maps to either ``request.headers["Host"]`` or242``request.authority``, depending on whether it's HTTP/1.x or HTTP/2.0.243 244*See also:* `Request.authority`,`Request.host`, `Request.pretty_host`245�HostN)r�r�r�r�r?r�rWs r*�host_header�Request.host_header�sT���=�=�D�M�M��>�>�H�T�Y�Y�%6�%6�%:�%:�6�4�%H�H��9�9�$�$�(�(���6�6r,c�|�UcPUR(dUR(aSURlURRSS5 gUR(dUR(aXlUR(dUR(aSUR;aXRS'gg)Nr,rK)r�r�r�r�r?rr=s  r*rLrM�sp���;��}�}��
�
�&)��	�	�#��L�L���V�T�*��}�}��
�
�!$���M�M�T�]�]�v����7M�'*���V�$�8Nr,c�.�URR$)z246Target port.247)r�r�rWs r*r��Request.port�s��248�y�y�~�~�r,c��[U[5(d[SU<S35eXRlUR5 g)NzPort must be an integer, not r,)r8r|r�r�r�rI)r>r�s  r*r�rP�s9���$��$�$��<�T�H�A�F�G�G��	�	���'�'�)r,c��[R"URURUR5nSUR249R;aXR250RS'UR251R(aXlgg)NrK)rr!r�r�r�r�r?r�r=s  r*rI�"Request._update_host_and_authority�s]���l�l�4�;�;��	�	�4�9�9�=���T�Y�Y�&�&�&�(+�I�I���f�%��9�9��� �N�r,c�N�URRRSS5$)a+252HTTP request path, e.g. "/index.html" or "/index.html?a=b".253Usually starts with a slash, except for OPTIONS requests, which may just be "*".254 255This attribute includes both path and query parts of the target URI256(see Sections 3.3 and 3.4 of [RFC3986](https://datatracker.ietf.org/doc/html/rfc3986)).257r&r')r�r�r(rWs r*r��Request.path	s ���y�y�~�~�$�$�W�.?�@�@r,c�<�[USS5URlgr%)rr�r�r=s  r*r�rUs��%�c�7�4E�F��	�	�r,c��URS:XaURSUR3$URS:waUROSn[R258"URURURU5$)z�259The full URL string, constructed from `Request.scheme`, `Request.host`, `Request.port` and `Request.path`.260 261Settings this property updates these attributes as well.262r�r�*r�)r7r�r�r�r�unparser��r>r�s  r*r�Request.urlsb���!�!�[�0��i�i�[��$�)�)��-�-� �I�I��,�t�y�y�"���{�{�4�;�;��	�	�4�9�9�d�C�Cr,c�|�[USS5n[R"U5uUlUlUlUlgr%)r r�parser�r�r�r�r=s  r*rr[$s/����g�'8�9��7:�y�y��~�4���T�Y��	�4�9r,c�p�URnU(a[R"USS9S$UR$)aJ263*Read-only:* Like `Request.host`, but using `Request.host_header` header as an additional (preferred) data source.264This is useful in transparent mode where `Request.host` is only an IP address.265 266*Warning:* When working in adversarial environments, this may not reflect the actual destination267as the Host header could be spoofed.268F��checkr)rLr�parse_authorityr�)r>r�s  r*�pretty_host�Request.pretty_host)s4���$�$�	���&�&�y��>�q�A�A��9�9�r,c��URS:XaUR$URnU(dUR$[R"USS9up#U=(d) [R269"UR5=(d SnURS:waUROSn[R"URX#U5$)z]270*Read-only:* Like `Request.url`, but using `Request.pretty_host` instead of `Request.host`.271r�Fr_i�rXr�)	r7r�rLrra�default_portr�r�rY)r>rLrb�pretty_portr�s     r*�272pretty_url�Request.pretty_url8s���273�!�!�[�0��>�>�!��&�&����8�8�O�#&�#6�#6�{�%�#P� ��!�I�S�%5�%5�d�k�k�%B�I�c�� �I�I��,�t�y�y�"���{�{�4�;�;��$�G�Gr,c��[RRUR5Rn[[R"U55$rM)�urllibr]�urlparser�queryrwr()r>rls  r*�274_get_query�Request._get_queryJs4�����%�%�d�h�h�/�5�5���S�Z�Z��&�'�'r,c���[R"U5n[RR	UR5u p4pSn[RRSSXEX&/5Ulg)Nr�)rr�rjr]rk�275urlunparser�)r>�276query_datarl�_r��params�fragments       r*�277_set_query�Request._set_queryNsP���278�279�:�&��*0�,�,�*?�*?����*I�'��1�F�x��L�L�+�+�R��T�5�,S�T��	r,c�X�[R"URUR5$)z�280The request query as a mutable mapping view on the request's path.281For the most part, this behaves like a dictionary.282Modifications to the MultiDictView update `Request.path`, and vice versa.283)r�
MultiDictViewrmrurWs r*rl�
Request.querySs���&�&�t������H�Hr,c�&�URU5 grM)rur�s  r*rlry\s������r,c�v�URRS5n[[R"U55$)N�Cookie)r?rarwr�parse_cookie_headersr�s  r*�_get_cookies�Request._get_cookies`s,���L�L� � ��*���W�1�1�!�4�5�5r,c�J�[R"U5URS'g)N�cookie)r�format_cookie_headerr?r�s  r*�_set_cookies�Request._set_cookiesds��!(�!=�!=�e�!D����X�r,c�X�[R"URUR5$)z�284The request cookies.285For the most part, this behaves like a dictionary.286Modifications to the MultiDictView update `Request.headers`, and vice versa.287�rrxr~r�rWs r*r�Request.cookiesgs#���&�&�t�'8�'8�$�:K�:K�L�Lr,c�&�URU5 grM�r�r�s  r*rr�p������%� r,c��[RRUR5Rn[SUR
S555$)zK288The URL's path components as a tuple of strings.289Components are unquoted.290c3�^# �UH#o(dM[R"U5v� M% g7frM)r�unquote)rS�is  r*rU�*Request.path_components.<locals>.<genexpr>~s���B�_���^�S�[�[��^�^�_�s�291-�-�/)rjr]rkrr�rw�splitrZs  r*�path_components�Request.path_componentsts=���|�|�$�$�T�X�X�.�3�3���B�T�Z�Z��_�B�B�Br,�292componentsc���[SU5nSSRU5-n[RR	UR2935u  p4pV[RR
SSX$XV/5Ulg)Nc�,�[R"USS9$)Nr�)�safe)r�quoter)s r*�<lambda>�)Request.path_components.<locals>.<lambda>�s��3�9�9�Q�R�#8r,r�r�)�maprHrjr]rkrrpr�)r>r�r�rrrsrlrts       r*r�r��sb���8�*�E�294��S�X�X�j�)�)��+1�<�<�+@�+@����+J�(��1�a���L�L�+�+�R��T�5�,S�T��	r,c�R�SnUHnURRUS5 M! g)zO295Modifies this request to remove headers that might produce a cached response.296)zif-modified-sincez
if-none-matchN)r?r)r>�297delheadersr�s   r*�	anticache�Request.anticache�s)��298�299��A��L�L���Q��%�r,c�"�SURS'g)zJ300Modify the Accept-Encoding header to only accept uncompressed responses.301r��accept-encodingN)r?rWs r*�anticomp�Request.anticomp�s��+5����&�'r,c�^�URRS5mT(a)SRU4SjS55URS'gg)z[302Limits the permissible Accept-Encoding values, based on what we can decode appropriately.303r�rFc3�8># �UHnUT;dMUv� M g7frMr2)rS�e�accept_encodings  �r*rU�-Request.constrain_encoding.<locals>.<genexpr>�s"����8�F�A���'���F�s�304�	>�br�gzip�zstd�deflater�N)r?r�rH)r>r�s @r*�constrain_encoding�Request.constrain_encoding�sG����,�,�*�*�+<�=���.2�i�i�8�F�8�/�D�L�L�*�+�r,c���SURRSS5R5;nU(a,[[R305"UR
SS955$g)N�!application/x-www-form-urlencodedr�r�Frr2)r?r�rNrwrr(r��r>�is_valid_content_types  r*�_get_urlencoded_form�Request._get_urlencoded_form�sS��/��|�|�����3�9�9�;�
<�	�!�����D�M�M��M�$?�@�A�A�r,�	form_datac��SURS'[R"XRSS95R5Ulg)z�306Sets the body to the URL-encoded form data, and adds the appropriate content-type header.307This will overwrite the existing content if there is one.308r�r�FrN)r?rr�r�r�)r>r�s  r*�_set_urlencoded_form�Request._set_urlencoded_form�s7��309(K����^�$��z�z�)�]�]�%�]�-H�I�P�P�R��r,c�X�[R"URUR5$)z�310The URL-encoded form data.311 312If the content-type indicates non-form data or the form could not be parsed, this is set to313an empty `MultiDictView`.314 315Modifications to the MultiDictView update `Request.content`, and vice versa.316)rrxr�r�rWs r*�urlencoded_form�Request.urlencoded_form�s(���&�&��%�%�t�'@�'@�317�	318r,c�&�URU5 grM)r�r�s  r*r�r��s���!�!�%�(r,c� �SURRSS5R5;nU(aHURb;[R319"URRS5UR5$/$![a /$f=f)N�multipart/form-datar�r�)r?r�rNr�r�decode_multipartr�r�s  r*�_get_multipart_form�Request._get_multipart_form�s���!�T�\�\�%5�%5�n�b�%I�%O�%O�%Q�Q�	�!�T�\�\�%=�
� �1�1��L�L�$�$�^�4�d�l�l���320�	���
���	�
�s�9A?�?321B
�B
rAc�`�URRSS5nUR5RS5nU(dQS[R322"[R"S55R5-nSU<3=URS'n[R"X!5Ulg)Nr�r�r�z--------------------�zmultipart/form-data; boundary=)r?r�rN�323startswith�binascii�hexlify�os�urandomr(r�encode_multipartr�)r>rAr�r��boundarys     r*�_set_multipart_form�Request._set_multipart_form�s���
�\�\�
�
�n�b�
1�� "���324� 5� 5�6K� L��$�
� �(�"2�"2�2�:�:�b�>�"B�"I�"I�"K�K�H�2Q��}�0U�U�D�L�L��(�2� �1�1�"�<��r,c�X�[R"URUR5$)z�325The multipart form data.326 327If the content-type indicates non-form data or the form could not be parsed, this is set to328an empty `MultiDictView`.329 330Modifications to the MultiDictView update `Request.content`, and vice versa.331)rrxr�r�rWs r*�multipart_form�Request.multipart_form�s(���&�&��$�$�d�&>�&>�332�	333r,c�&�URU5 grM)r�r�s  r*r�r��s��� � ��'r,)r�r�r�r�r�r�r�)r�r2)r#N)6rrrsrtrurvr�rxrzr|r9r0rwr�r7r"r�r-rr1rr7r�rr�r�r�rLr�rIr�rrbrgrmrurrxrlr~r�rr�r�r�r�r�rr�r�r{r�r�r�r}r2r,r*rrs������1334��1335��1336��	1337�338�1339��
1340��1341��1342��5��u�e�|�!4�c�!9�:�:�1343����1344��E�%��u��"5�s�":�;�;�d�B�1345��1346��t�|�1347�f:�#�:��348 "�
�:��:��:����	:�
�d�3��;��e��3�4�4�x��e�U�l�@S�7T�T�
:�349�:��:�x��3�����K��K��K��]�]�I�#��+�I�$�I��I��C��C��C��]�]�I�#��+�I�$�I��I��I�3�I��I�"���"�S�5�[�"�T�"��"��350�c�351��352�353�[�[�*��e��*��*��*��7�S�4�Z�7��7����354+�t�c�z�E�1�355+�d�356+��357+���c����358�[�[�*��*��*��*�!��A�c�A��A�359�[�[�G��e��G��G��G��	D�S�	D��	D�	�Z�Z�F�s�U�{�F�t�F��F���S�����H�C�H��H�"(�U�360�I�y�.�.�s�C�x�8�I��I��\�\����6�E��M��0�0��c��:�M��M�
�^�^�!��!��	C��s�C�x��	C��	C����U�(�3�-�U��U�	&�5�361��S�h�u�S�#�X��.G�S�D�S��362��!8�!8��c��!B�363��364����)��)��T�%��u��*=�%>��=��e�E�5�L�.A�)B�=�t�=��365�	� 7� 7��u�� E�366��367����(�D��u�e�|�)<�$=�(�$�(��(r,rc�6�\rSrSr%Sr\\S'S\S\S\S\	\368\369\\4S4-S	\S370-SS371\	-\372\373\\4S4-S\S
\S374-4SjrS\
4Sjr\SS\S	\\
-S\	\\
\
\-4-\\375\\4-SS4Sjj5r\S\4Sj5r\R*S\SS3764Sj5r\S\
4Sj5r\R*S\
\-SS3774Sj5rSrSr\S\R4\
\378\
\R6\
\
S379-4444Sj5r\R*S5rSSjrSrg380)�Responsei�z381An HTTP response.382r�r�r�r�r?.r�Nr�r�r�c	��[U[5(aURSS5n[U[5(aURSS5n[U[5(a![S[	U5R38335e[U[5(d[
U5nUb [U[5(d[
U5n[UUUUUUUUS9Ulg)Nrr�r)r�r�r�r?r�r�r�r�)	r8rzr�r�r�rrr0r�r�)	r>r�r�r�r?r�r�r�r�s	         r*r7�Response.__init__�s����l�C�(�(�'�.�.�w��A�L��f�c�"�"��]�]�7�H�5�F��g�s�#�#��:�4��=�;Q�;Q�:R�S�T�T��'�7�+�+��g�&�G���384�8�W�(E�(E��x�(�H� �%�#�����+�'�	385��	r,r#c���UR(aMURRSS5n[R"[UR55nUSU3nOSnSURSUS3$)Nr�zunknown content typerFz386no contentz	Response(r )r�r?r�r�pretty_sizer�r�)r>r��size�detailss    r*r"�Response.__repr__sm��������!�!�.�2H�I�B��$�$�S��)9�)9�%:�;�D���B�t�f�o�G�"�G��4�+�+�,�B�w�i�q�9�9r,c��[U[5(aUnO�[U[5(a![SUR555nON[U[5(a[U5nO-[SR
[U5R55eU"SU[RRUS5R5USS[R"5[R"55n[U[5(aX$lU$[U[ 5(aX$lU$[S[U5RS35e)z/387Simplified API for creating response objects.388c3�Z# �UH!up[USS5[USS54v� M# g7fr&rrls   r*rU� Response.make.<locals>.<genexpr>7r(r)r*r�r�Nr+r,)r8r0r-r<rr:r.r�rrr�	RESPONSESr�r�r/r9r�rzr�)r�r�r�r?�resps     r*r1�
Response.make(s,���g�w�'�'��G�
���
&�
&���389$�M�M�O���G����
*�
*��g�&�G��H�O�O���M�*�*���
�����"�"�&�&�{�B�7�>�>�@�����I�I�K��I�I�K�	390���g�u�%�%�"�L������
%�
%��I���	�>�t�G�}�?U�?U�>V�VW�X��
r,c�.�URR$)z!391HTTP Status Code, e.g. ``200``.392�r�r�rWs r*r��Response.status_code^s��393�y�y�$�$�$r,c�$�XRlgrMr�)r>r�s  r*r�r�es�� +�	�	�r,c�L�URRRS5$)z�394HTTP reason phrase, for example "Not Found".395 396HTTP/2 responses do not contain a reason phrase, an empty string will be returned instead.397�398ISO-8859-1)r�r�r(rWs r*r��Response.reasonis���y�y���&�&�|�4�4r,c�P�[R"US5URlg)Nr�)rrr�r�)r>r�s  r*r�r�ss��#�0�0���F��	�	�r,c��URRS5n[R"U5n[	SU55$)N�399set-cookiec3�0# �UHupo1X#44v� M g7frMr2)rSrBrA�attrss    r*rU�(Response._get_cookies.<locals>.<genexpr>zs���R�k�0B��U�U�N�+�k�s�)r?rar�parse_set_cookie_headersrw)r>r��all_cookiess   r*r~�Response._get_cookiesws7���L�L� � ��.���6�6�q�9���R�k�R�R�Rr,c��/nUH5up4[R"X4SUS4/5nURU5 M7 URR	SU5 g)Nr�r�)r�format_set_cookie_header�appendr?rd)r>rA�cookie_headersrmrn�headers      r*r��Response._set_cookies|sV�����D�A��5�5��Q�4��1���6G�H�F��!�!�&�)��	
�����\�>�:r,c�X�[R"URUR5$)a�400The response cookies. A possibly empty `MultiDictView`, where the keys are cookie401name strings, and values are `(cookie value, attributes)` tuples. Within402attributes, unary attributes (e.g. `HTTPOnly`) are indicated by a `None` value.403Modifications to the MultiDictView update `Response.headers`, and vice versa.404 405*Warning:* Changes to `attributes` will not be picked up unless you also reassign406the `(cookie value, attributes)` tuple directly in the `MultiDictView`.407r�rWs r*r�Response.cookies�s#���&�&�t�'8�'8�$�:K�:K�L�Lr,c�&�URU5 grMr�r�s  r*rr��r�r,c�H�U(d[R"5nXR-408n/SQnUH[nX@R;dM[URU5nU(dM5[	U5U-n[USS9URU'M] /nURRS5H+n[R"X�5n	URU	5 M- U(aURRSU5 gg![a M�f=f![a Un	NYf=f)z�409This fairly complex and heuristic function refreshes a server410response for replay.411 412 - It adjusts date, expires, and last-modified headers.413 - It adjusts cookie expiration.414)�date�expiresz
last-modifiedT)�usegmtr�N)
r/r�r?rrr415�OSErrorrar�refresh_set_cookie_headerr�r�rd)416r>�now�delta�refresh_headersr��d�new�c�set_cookie_header�	refresheds417          r*�refresh�Response.refresh�s����)�)�+�C��*�*�*��418��419!�A��L�L� � ����a��1���1�#�A�,��.�C��*4�S��*F����Q��
!�
��!%���!5�!5�l�!C��
.�#�=�=�>O�W�	�
�H�H�Y��"D�
��L�L� � ��q�1�
��#������
.�-�	�
.�s$�5D�1D�420D�D�D!� D!)r�)��r,r2rM)rrrsrtrurvr�rxr9r|r0rwr�r7rzr"r�rrr1rr�rr�r~r�rrx�	MultiDictrrr}r2r,r*r�r��s�����!421��!422��!423��	!424�425�5��u�e�|�!4�c�!9�:�:�!426����
!427���.�5��u�e�|�)<�c�)A�#B�B�!428��!429��t�|�!430�F:�#�:���"�
�
3��3����3�431
�g�c�3��;�.�/�/�(�5����;N�2O�O�3�432�3��3�j�%�S�%��%����,�s�,�t�,��,��5��5��5��]�]�G�S�5�[�G�T�G��G�S�433;��M�	�	 �	 ��e�C��1D�1D�S�#�PT�*�_�1U�,U�&V�!V�	W�M��M�
�^�^�!��!�!2r,r�c�J^�\rSrSr%Sr\\S'Sr\S-\S'Sr	\434RS-\S'Sr\
S-\S'S\R4U4S	jjrS435\RSS4U4SjjrSr\S\4S
j5r\S\4Sj5r\R0S\SS4Sj5rU4SjrSrU=r$)�HTTPFlowi�zP436An HTTPFlow is a collection of objects representing a single HTTP437transaction.438�requestN�response�error�	websocketr#c�>�0[TU]5EURR5UR(aURR5OSUR(aURR5S.E$SS.E$)N)rrr)r6r�rrr)r>rCs �r*r��HTTPFlow.get_state�sq���439��g��!�440��|�|�-�-�/�59�]�]��
�
�/�/�1��7;�~�~����1�1�3�	441�	442�LP�	443�	444r,r�c�H>�[RURS55UlURS5=n(a[RU5OSUlURS5=n(a[R"U5OSUl[TU]%U5 g)Nrrr)445rr�rrr�rr!rr6r�)r>r��r�wrCs    �r*r��HTTPFlow.set_state�s����)�)�%�)�)�I�*>�?���8=�	�	�*�8M�3M�1�3M��+�+�A�.�TX��
�16���;�1G�,G�A�,G�M�$�$�Q�'�d�	
��	���%� r,c�~�SnSH"n[XS5(dMUSUSUS3-
nM$ US-
nURUS9$)	Nz	<HTTPFlow)rrrr�client_conn�server_connFz
446  z	 = {flow.�}�>r)r�r.)r>�s�as   r*r"�HTTPFlow.__repr__�sW����447�A��t��&�&��v�a�S�448�1�#�R�0�0��449�	450�S����x�x�T�x�"�"r,c�.�URR$)z4*Read-only:* An alias for `Request.timestamp_start`.)rr�rWs r*r��HTTPFlow.timestamp_start�s���|�|�+�+�+r,c�P�[R"S[SS9 [USS5$)N�HTTPFlow.mode is deprecated.r���451stacklevel�_mode�regular)�warnings�warn�DeprecationWarningr�rWs r*�mode�
HTTPFlow.mode�s$���
�
�4�6H�UV�W��t�W�i�0�0r,r�c�D�[R"S[SS9 Xlg)Nr#r�r$)r(r)r*r&r=s  r*r+r,�s���
�
�4�6H�UV�W��452r,c��>�[TU]5nUR(aURR5UlUR(aURR5UlU$rM)r6r�rr)r>�frCs  �r*r��
HTTPFlow.copysI����G�L�N���<�<����)�)�+�A�I��=�=����+�+�-�A�J��r,)r&rrr)rrrsrtrurvrrxrr�rr�Errorrr!r�Stater�r�r"rr�r�rzr+rr�r}r~rs@r*r
r
�s�����453��$� $�H�h��o�$�%�#�E�4�:�:���#��'+�I�}�t�#�*��454�<�-�-�455�!�|�1�1�!�d�!�
#��,��,��,��1�c�1��1�456�[�[���������r,r
)r
r�rr�r0)@r�rr�r/�urllib.parserjr(�collections.abcrrrrr�dataclassesrr	�email.utilsr457rr�typingr
r�	mitmproxyr�mitmproxy.coretypesrr�
mitmproxy.netr�mitmproxy.net.httprrrr�mitmproxy.net.http.headersrrr�mitmproxy.utilsrrr�mitmproxy.utils.strutilsrr �mitmproxy.websocketr!r9rzr+r.rr0�Serializabler�r�r�r�rr��Flowr
�__all__r2r,r*�<module>rCsU����	����$�$�$�#�$�!��"�!�$����)�,�"�&�(�+�"�<�=�9�!�$�%�1�/�-�0�u�0��0�@�S�5�[�@�U�@�458#�i�!�!�#�D�"�,�+�+�"��"�J��+������;����459X1�l�'�'�X1�vn(�g�n(�bB2�w�B2�JL�t�y�y�L�^�r,
codekingpro/portable-devtools · Team Ai