Team Ai
Datasetpublic

codekingpro/portable-devtools

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

2��j������SrSSKrSSKrSSKrSSKrSSKrSSKrSSK	J3r4 SSKJr SSK
rSSKrSSKJr SSKrSSKrSSKJrJrJrJr SSKJrJrJrJr SSKJrJ r  \ SSK!r!SS	K!J"r"J#r#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+J,r, \!RZ(a,SS5K!J.r. SSK/J0r0 SSK1r1\RdRf\4\44r5O\RdRfr5Sr6\Rn"S
5r8"SS5r9\6"S5S\4S\44Sj5r:"SS\55r;"SS5r<"SS\=5r>"SS\=5r?"SS5r@"SS5rA"S S!5rBS"\4S#\(S\'\4\44\$\"\4\44\"\"\4\44S$44S\44S%jrC"S&S'\5rDS(\4S\)\"\)\E\)\E44S)jrFS*\)\ES+\)\ES,\ES\44S-jrGS.\4S\)\E4S/jrH\R�"S0S155rJ\R�"S2S355rK\K"5qLS4\KSS4S5jrMS^SS6.S7\4S8\NS9\'\4\$\N4S:\'\4\$\D4S;\)\;S4\)\KSS4S<jjjrOSS6.S=\NS>\NS9\'\4\$\N4S:\'\4\$\D4S4\)\JSS4S?jjrPS@\(\E\Q\R\R�\R4S\44SAjrT"SBSC\!R�5rVSD\4S\V4SEjrW"SFSG\!R�5rXSD\4S\X4SHjrYSI\4S\+\4SS44SJjrZSD\4S\"\4\'\4\4444SKjr[SL\4SM\'\4\44S\44SNjr\SO\(\4\N4SP\(\4\N4S\N4SQjr]SRr^\Rn"SS5r_ST\4S\"\4\)\E44SUjr`SV\'\4\$\,4S\#\"\4\,44SWjra\Rn"SX5R�rcSY\R�S\44SZjreSI\4S\44S[jrfS\\4S\'\4\444S]jrgg)_z�HTTP utility code shared by clients and servers.7 8This module also defines the `HTTPServerRequest` class which is exposed9via `tornado.web.RequestHandler.request`.10�N)�	lru_cache)�	responses)�SSLError)�	urlencode�urlparse�11urlunparse�	parse_qsl)�12native_str�parse_qs_bytes�utf8�13to_unicode)�14ObjectDict�unicode_type)�Tuple�Iterable�List�Mapping�Iterator�Dict�Union�Optional�	Awaitable�	Generator�AnyStr)�Deque)�Futurez 	z[\x00-\x08\x0A-\x1F\x7F]c15���\rSrSrSr\R"S5r\R"S5r\R"S5r	\R"S\RS\RS\	RS35r\R"S	5r\R"S165r
\R"S5r\R"S\
RS\RS
35r\R"S\RS\RS\RS\R35r\R"S5r\R"\RS35r\r\r\R"S\RS\RS35r\R"S5r\R"S\
RS\RS35r\R"\RS35r\R"S\RS\RS\RS
35r\R"S5r\R"S\RS\RS\RS35rSrg)�_ABNF�OaiClass that holds a subset of ABNF rules from RFC 9110 and friends.17 18Class attributes are re.Pattern objects, with the same name as in the RFC19(with hyphens changed to underscores). Currently contains only the subset20we use (which is why this class is not public). Unfortunately the fields21cannot be alphabetized as they are in the RFCs because of dependencies.22z[A-Za-z0-9\-._~]z
[!$&'()*+,;=]z%[0-9A-Fa-f]{2}z(?:[\[\]:]|�|z)*z[0-9]*z[\x21-\x7E]z[\x80-\xFF]z(?:�)z| |\t)*z[!#$%&'*+\-.^_`|~0-9A-Za-z]�+z)(?::z)?zHTTP/[0-9]\.[0-9]z	(?:[\t ]|z)+�(z) (z[0-9]{3}�N)�__name__�23__module__�__qualname__�__firstlineno__�__doc__�re�compile�uri_unreserved�uri_sub_delims�uri_pct_encoded�pattern�uri_host�uri_port�VCHAR�obs_text�field_vchar�field_value�tchar�token�24field_name�method�host�HTTP_version�
reason_phrase�request_target�request_line�status_code�status_line�__static_attributes__r$��VD:\code\apps\devtools\python\user_packages\Python313\site-packages\tornado/httputil.pyrrOsQ����Z�Z� 3�4�N��Z�Z� 0�1�N��j�j�!3�4�O��z�z��~�-�-�.�a��0F�0F�/G�q��I`�I`�Ha�ac�d��H��z�z�)�$�H�
�J�J�~�&�E��z�z�.�)�H��*�*��E�M�M�?�!�H�4D�4D�3E�Q�G�H�K��*�*����� ����� ��K�$7�$7�#8���@S�@S�?T�	V��K�25
�J�J�5�6�E��J�J�5�=�=�/��+�,�E��J�
�F�
�:�:��X�-�-�.�e�H�4D�4D�3E�R�H�I�D��:�:�2�3�L��J�J�)�E�M�M�?�!�H�<L�<L�;M�R�P�Q�M��Z�Z�K�$7�$7�#8�� :�;�N��:�:��V�^�^��C�� 6� 6�7�s�<�;O�;O�:P�PQ�R��L��*�*�[�)�K��*�*��\�
!�
!�"�#�k�&9�&9�%:�#�m�>S�>S�=T�TV�W��KrBri��name�returnc��SRURS5Vs/sHoR5PM sn5$s snf)z]Map a header name to Http-Header-Case.26 27>>> _normalize_header("coNtent-TYPE")28'Content-Type'29�-)�join�split�30capitalize)rD�ws  rC�_normalize_headerrL�s1���8�8�T�Z�Z��_�=�_��\�\�^�_�=�>�>��=s�?c	�f�\rSrSrSr\RS\\\	\4SS4Sj5r31\RS\\\4SS4Sj5r32\RS\\\4SS4S	j5r33\RS34\SS4Sj5r35S\RS36\SS4Sjr37S
S.S\S\S\
SS4SjjrS\S\	\4SjrS\\\\44SjrS
S.S\S\
SS4Sjjr\S
S.S\S\
SS4Sjj5rS\S\SS4SjrS\S\
4SjrS\S\4SjrS\SS4SjrS\4SjrS\\R4SjrS"Sjr\rS\4S jr \ r!S!r"g)#�HTTPHeaders�a�A dictionary that maintains ``Http-Header-Case`` for all keys.38 39Supports multiple values per key via a pair of new methods,40`add()` and `get_list()`.  The regular dictionary interface41returns a single value per key, with multiple values joined by a42comma.43 44>>> h = HTTPHeaders({"content-type": "text/html"})45>>> list(h.keys())46['Content-Type']47>>> h["Content-Type"]48'text/html'49 50>>> h.add("Set-Cookie", "A=B")51>>> h.add("Set-Cookie", "C=D")52>>> h["set-cookie"]53'A=B,C=D'54>>> h.get_list("set-cookie")55['A=B', 'C=D']56 57>>> for (k,v) in sorted(h.get_all()):58...    print('%s: %s' % (k,v))59...60Content-Type: text/html61Set-Cookie: A=B62Set-Cookie: C=D63�_HTTPHeaders__argrENc��g�Nr$��selfrPs  rC�__init__�HTTPHeaders.__init__����rBc��grRr$rSs  rCrUrV�rWrB�argsc��grRr$)rTrYs  rCrUrV�rWrB�kwargsc��grRr$)rTr[s  rCrUrV�rWrBc��0Ul0UlSUl[U5S:XaU[U5S:XaF[	US[645(a.USR
5Hup4URX45 M gUR"U0UD6 g)N�r)	�_as_list�_combined_cache�	_last_key�len�65isinstancerN�get_all�add�update)rTrYr[�k�vs     rCrUrV�su��/1��
�/1�������t�9��>�c�&�k�Q�.�:�d�1�g�{�3S�3S��Q����)��������*�
�K�K��(��(rBT��_chars_are_bytesrD�valuerjc���[RRU5(d[SU-5eU(a<[RR[U55(d[SU-5eO([RU5(a[SU-5e[U5nX@l	X@;a;URRUS5 URURU5 gX U'g)z#Adds a new value for the given key.zInvalid header name %r�Invalid header value %rN)rr8�	fullmatch�HTTPInputErrorr5r
�_FORBIDDEN_HEADER_CHARS_RE�searchrLrar`�popr_�append)rTrDrkrj�	norm_names     rCre�HTTPHeaders.add�s������)�)�$�/�/� �!9�D�!@�A�A���$�$�.�.�z�%�/@�A�A�%�%>��%F�G�G�B�66*�0�0��7�7�$�%>��%F�G�G�%�d�+�	�"����� � �$�$�Y��5��M�M�)�$�+�+�E�2�#��OrBc�P�[U5nURRU/5$)z2Returns all values for the given header as a list.)rLr_�get�rTrDrts   rC�get_list�HTTPHeaders.get_list�s#��%�d�+�	��}�}� � ��B�/�/rBc#�n# �URR5HupUHnX4v� M67 M g7f)z�Returns an iterable of all (name, value) pairs.68 69If a header has multiple values, multiple pairs will be70returned with the same name.71N)r_�items)rTrD�valuesrks    rCrd�HTTPHeaders.get_all�s2���!�M�M�/�/�1�L�D����m�#� �2�s�35�linec���[R"SU5=n(aUSUR5nU(dgUS[;a�URc[S5eSUR
[5-nU(a6[RRUSS5(d[SU-5eO([RU5(a[SU-5eURURS	==U-
ss'URRURS5 gURS72S5upVUR!XVR
[5US9 g![a [S5ef=f)
afUpdates the dictionary with a single header line.73 74>>> h = HTTPHeaders()75>>> h.parse_line("Content-Type: text/html")76>>> h.get('content-type')77'text/html'78>>> h.parse_line("Content-Length: 42\r\n")79>>> h.get('content-type')80'text/html'81 82.. versionchanged:: 6.583    Now supports lines with or without the trailing CRLF, making it possible84    to pass lines from AsyncHTTPClient's header_callback directly to this method.85 86.. deprecated:: 6.587   In Tornado 7.0, certain deprecated features of HTTP will become errors.88   Specifically, line folding and the use of LF (with CR) as a line separator89   will be removed.90z\r?\n$Nrz.first header line cannot start with whitespace� r^zInvalid header continuation %rrm������:zno colon in header lineri)r*rq�start�HTTP_WHITESPACEraro�striprr5rnrpr_r`rrrI�91ValueErrorre)rTrrj�m�new_partrDrks       rC�92parse_line�HTTPHeaders.parse_line�sV��(�	�	�)�T�*�*�1�*���!�'�'�)�$�D�����7�o�%��~�~�%�$�%U�V�V��T�Z�Z��8�8�H���(�(�2�2�8�A�B�<�@�@�(�)I�H�)T�U�U�A�.�4�4�X�>�>�(�)B�X�)M�N�N��M�M�$�.�.�)�"�-��9�-�� � �$�$�T�^�^�T�:�
@�"�j�j��a�0���
�H�H��k�k�/�2�EU�
�
���
@�$�%>�?�?�
@�s�(E � E6�headersc��U"5nSnURSU5nUS:XaURXSUS9 U$XUS-nUS-nURXbS9 MJ)aLReturns a dictionary from HTTP header text.93 94>>> h = HTTPHeaders.parse("Content-Type: text/html\r\nContent-Length: 42\r\n")95>>> sorted(h.items())96[('Content-Length', '42'), ('Content-Type', 'text/html')]97 98.. versionchanged:: 5.199 100   Raises `HTTPInputError` on malformed headers instead of a101   mix of `KeyError`, and `ValueError`.102 103r�104r�Nrir^)�findr�)�clsr�rj�hr��lfrs       rC�parse�HTTPHeaders.parse(su��8
�E��������d�E�*�B��R�x����W�V�_�?O��P�����2��6�*�D���F�E�
�L�L��L�A�rBc�V�[U5nX RU'U/URU'grR�rLr`r_)rTrDrkrts    rC�__setitem__�HTTPHeaders.__setitem__Ss*��%�d�+�	�*/���Y�'�$)�7��
�
�i� rBc�`�[U[5(dg[U5nX R;$)NF)rc�strrLr_rxs   rC�__contains__�HTTPHeaders.__contains__Xs+���$��$�$��%�d�+�	��M�M�)�)rBc��[U5nX R;a+SRURU5URU'URU$)N�,)rLr`rHr_)rTrD�headers   rC�__getitem__�HTTPHeaders.__getitem__`sK��"�4�(���-�-�-�+.�8�8�D�M�M�&�4I�+J�D� � ��(��#�#�F�+�+rBc�N�[U5nURU	URU	grRr�rxs   rC�__delitem__�HTTPHeaders.__delitem__fs&��%�d�+�	�� � ��+��M�M�)�$rBc�,�[UR5$rR)rbr_�rTs rC�__len__�HTTPHeaders.__len__ks���4�=�=�!�!rBc�,�[UR5$rR)�iterr_r�s rC�__iter__�HTTPHeaders.__iter__ns���D�M�M�"�"rBc��[U5$rR)rNr�s rC�copy�HTTPHeaders.copyqs
���4� � rBc��/nUR5Hup#URUSUS35 M SRU5$)Nz: r��)rdrsrH)rT�linesrDrks    rC�__str__�HTTPHeaders.__str__zs@�����<�<�>�K�D��L�L�D�6��E�7�"�-�.�*��w�w�u�~�rB)r_r`ra)rErN)#r%r&r'r(r)�typing�overloadrr�rrUr�Any�boolreryrrdr��classmethodr�r��objectr�r�r��intr�rr�r��__copy__r��__unicode__rAr$rBrCrNrN�s���8�_�_�
�g�c�4��9�n�5�
�$�
��
��_�_�
�g�c�3�h�/�
�D�
��
��_�_�
�e�C��H�o�
�$�
��
��_�_�
��
��
��
�)�f�j�j�)�C�)�D�)�(FJ�$��$�C�$�d�$�d�$�(0�S�0�T�#�Y�0�105$��%��S��/�2�$�AE�1�s�1��1��1�f�=A�&�C�&�d�&�m�&��&�T+��+�C�+�D�+�106*��*�D�*�,��,��,�%��%��%�107"��"�#�(�6�:�:�.�#�!��H�����KrBrNc�Z�\rSrSrSrSrSrSrSS\\	S\\	S\	S\\108S\\S	\\	S109\\\	\
S4S\S
S\SS\\SS4Sjjr\S\\	\R$R&44Sj5rS\	4SjrS\4SjrSS\S\S\\44SjjrSSjrS\	4SjrSrg)�HTTPServerRequesti�aC110A single HTTP request.111 112All attributes are type `str` unless otherwise noted.113 114.. attribute:: method115 116   HTTP request method, e.g. "GET" or "POST"117 118.. attribute:: uri119 120   The requested uri.121 122.. attribute:: path123 124   The path portion of `uri`125 126.. attribute:: query127 128   The query portion of `uri`129 130.. attribute:: version131 132   HTTP version specified in request, e.g. "HTTP/1.1"133 134.. attribute:: headers135 136   `.HTTPHeaders` dictionary-like object for request headers.  Acts like137   a case-insensitive dictionary with additional methods for repeated138   headers.139 140.. attribute:: body141 142   Request body, if present, as a byte string.143 144.. attribute:: remote_ip145 146   Client's IP address as a string.  If ``HTTPServer.xheaders`` is set,147   will pass along the real IP address provided by a load balancer148   in the ``X-Real-Ip`` or ``X-Forwarded-For`` header.149 150.. versionchanged:: 3.1151   The list format of ``X-Forwarded-For`` is now supported.152 153.. attribute:: protocol154 155   The protocol used, either "http" or "https".  If ``HTTPServer.xheaders``156   is set, will pass along the protocol used by a load balancer if157   reported via an ``X-Scheme`` header.158 159.. attribute:: host160 161   The requested hostname, usually taken from the ``Host`` header.162 163.. attribute:: arguments164 165   GET/POST arguments are available in the arguments property, which166   maps arguments names to lists of values (to support multiple values167   for individual names). Names are of type `str`, while arguments168   are byte strings.  Note that this is different from169   `.RequestHandler.get_argument`, which returns argument values as170   unicode strings.171 172.. attribute:: query_arguments173 174   Same format as ``arguments``, but contains only arguments extracted175   from the query string.176 177   .. versionadded:: 3.2178 179.. attribute:: body_arguments180 181   Same format as ``arguments``, but contains only arguments extracted182   from the request body.183 184   .. versionadded:: 3.2185 186.. attribute:: files187 188   File uploads are available in the files property, which maps file189   names to lists of `.HTTPFile`.190 191.. attribute:: connection192 193   An HTTP request is attached to a single HTTP connection, which can194   be accessed through the "connection" attribute. Since connections195   are typically kept open in HTTP/1.1, multiple requests can be handled196   sequentially on a single connection.197 198.. versionchanged:: 4.0199   Moved from ``tornado.httpserver.HTTPRequest``.200 201.. deprecated:: 6.5.2202   The ``host`` argument to the ``HTTPServerRequest`` constructor is deprecated. Use203   ``headers["Host"]`` instead. This argument was mistakenly removed in Tornado 6.5.0 and204   temporarily restored in 6.5.2.205Nr9�uri�versionr��bodyr:�files�HTTPFile�206connection�HTTPConnection�207start_line�RequestStartLine�server_connectionrEc���U	bU	upnXlX lX0lU=(d208 [5UlU=(d SUl[
USS5n[
USS5Ul[
USS5UlU=(d URSUl	[RRUR5(d[S209UR-5eSUR;a[SUR-5e[URR55S
UlU=(d 0UlX�lX�l[(R("5UlSUlUbUR/S5uUlo�l[5UR2SS9Ul:"UR65Ul0Ulg![a US:Xa210SUl	GNW[S	5ef=f)NrB�context�	remote_ip�protocol�http�Host�HTTP/1.0z	127.0.0.1zMissing Host headerzInvalid Host header: %rr�z%Multiple host headers not allowed: %rr�?T��keep_blank_values) r9r�r�rNr�r��getattrr�r�r:�KeyErrorrorrn�split_host_and_port�lower�	host_namer�r�r��time�_start_time�_finish_time�	partition�path�queryr�	argumentsr��deepcopy�query_arguments�body_arguments)
rTr9r�r�r�r�r:r�r�r�r�r��seps
             rCrU�HTTPServerRequest.__init__�s����!�#-� �F���������/�+�-����K�C��	��*�i��6�� ��+�t�<������V�<��
�	<��4����V� 4�D�I��z�z�#�#�D�I�I�.�.� �!:�T�Y�Y�!F�G�G��$�)�)��"!�!H�4�9�9�!T�U�U�,�T�Y�Y�_�_�->�?��B����[�b��211�$��!2���9�9�;��� ����?�),���s�);�&�D�I�s�J�'��212�213�d�K���#�}�}�T�^�^�<��� ����K�	<��*�$�'��	�$�%:�;�;�	<�s�5G�G5�)G5c��[US5(d�[RR5UlSUR214;aM[
UR215S5nUR5Hup#X0RU'M UR$UR$![a M=f=f![a UR$f=f)z0A dictionary of ``http.cookies.Morsel`` objects.�_cookies�Cookie)	�hasattrr��cookies�SimpleCookier�r��parse_cookier|�	Exception)rT�parsedrgrhs    rCr��HTTPServerRequest.cookies.s����t�Z�(�(����)�)�+�
�M��4�<�<�'�!�)�$�,�,�x�*@�A�F�!'������!�/0�M�M�!�,�!/��}�}��t�}�}��� )�!�!�	!��
!����}�}���s$�B/�4B�216B,�+B,�/217C�Cc�T�URS-UR-UR-$)z+Reconstructs the full URL for this request.z://)r�r:r�r�s rC�full_url�HTTPServerRequest.full_urlEs#���}�}�u�$�t�y�y�0�4�8�8�;�;rBc��URc"[R"5UR-218$URUR-219$)z?Returns the amount of time it took for this request to execute.)r�r�r�r�s rC�request_time�HTTPServerRequest.request_timeIs<�����$��9�9�;��!1�!1�1�1��$�$�t�'7�'7�7�7rB�binary_formc��URcgURRRRUS9$![a gf=f)a�Returns the client's SSL certificate, if any.220 221To use client certificates, the HTTPServer's222`ssl.SSLContext.verify_mode` field must be set, e.g.::223 224    ssl_ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)225    ssl_ctx.load_cert_chain("foo.crt", "foo.key")226    ssl_ctx.load_verify_locations("cacerts.pem")227    ssl_ctx.verify_mode = ssl.CERT_REQUIRED228    server = HTTPServer(app, ssl_options=ssl_ctx)229 230By default, the return value is a dictionary (or None, if no231client certificate is present).  If ``binary_form`` is true, a232DER-encoded form of the certificate is returned instead.  See233SSLSocket.getpeercert() in the standard library for more234details.235http://docs.python.org/library/ssl.html#sslsocket-objects236N)r�)r��stream�socket�getpeercertr)rTr�s  rC�get_ssl_certificate�%HTTPServerRequest.get_ssl_certificatePsS��*	����&���?�?�)�)�0�0�<�<�'�=��
���	��	�s�
=�,=�237A238�	A239c�B�[URRSS5URURUR240UR5 URR
5H0upURRU/5RU5 M2 g)N�Content-Typer�)241�parse_body_argumentsr�rwr�r�r�r|r��242setdefault�extend)rTrgrhs   rC�_parse_body�HTTPServerRequest._parse_bodyosx����L�L���^�R�0��I�I�����J�J��L�L�	243��'�'�-�-�/�D�A��N�N�%�%�a��,�3�3�A�6�0rBc��SnSRUVs/sHo"S[X5<3PM sn5nURRSUS3$s snf)N)r�r:r9r�r�r�z, �=r#r!)rHr��	__class__r%)rT�attrs�nrYs    rC�__repr__�HTTPServerRequest.__repr__{sW��M���y�y�u�E�u�!�C�q���!1� 4�5�u�E�F���.�.�)�)�*�!�D�6��3�3��Fs�A)r�r�r�r�r�r�r�r�r�r:r�r9r�r�r�r�r�r�r�r�)244NNr�NNNNNNN)F�rEN)r%r&r'r(r)r�r��_body_futurerr�rN�bytesrrr�rU�propertyr�r��Morselr��floatr�r�rr�rrrAr$rBrCr�r��sr��_�B�D��E��L�!%�!�!�)-� $�"�7;�15�37�.2�A!���
�A!��c�]�A!��	A!�245�+�&�A!��u�o�
A!��s�m�A!���S�$�z�"2�2�3�4�A!��-�.�A!��/�0�A!�$�F�+�A!�246�A!�F���c�4�<�<�#6�#6�6�7����,<�#�<�8�e�8�#(����	�t�T�5� �	!��>2477�4�#�4rBr�c��\rSrSrSrSrg)roi�zeException class for malformed HTTP requests or responses248from remote sources.249 250.. versionadded:: 4.0251r$N�r%r&r'r(r)rAr$rBrCroro�s���	rBroc��\rSrSrSrSrg)�HTTPOutputErrori�zBException class for errors in HTTP output.252 253.. versionadded:: 4.0254r$Nrr$rBrCrr�s���255	rBrc�@�\rSrSrSrS\SSSS4SjrS\SS	4S256jrSrg	)�HTTPServerConnectionDelegatei�zWImplement this interface to handle requests from `.HTTPServer`.257 258.. versionadded:: 4.0259�server_conn�request_connr�rE�HTTPMessageDelegatec��[5e)a:This method is called by the server when a new request has started.260 261:arg server_conn: is an opaque object representing the long-lived262    (e.g. tcp-level) connection.263:arg request_conn: is a `.HTTPConnection` object for a single264    request/response exchange.265 266This method should return a `.HTTPMessageDelegate`.267��NotImplementedError)rTrrs   rC�
start_request�*HTTPServerConnectionDelegate.start_request�s
��"�#�#rBNc��g)z�This method is called when a connection has been closed.268 269:arg server_conn: is a server connection that has previously been270    passed to ``start_request``.271Nr$)rTrs  rC�on_close�%HTTPServerConnectionDelegate.on_close����	
rBr$)	r%r&r'r(r)r�rrrAr$rBrCrr�s7���272$�!�$�1A�$�	�$�
�F�
�t�
rBrc�r�\rSrSrSrS\SS\S\\S4Sjr	S	\273S\\S4S274jrSSjrSSjr
S
rg)ri�zWImplement this interface to handle an HTTP request or response.275 276.. versionadded:: 4.0277r��r��ResponseStartLiner�rENc��g)a�Called when the HTTP headers have been received and parsed.278 279:arg start_line: a `.RequestStartLine` or `.ResponseStartLine`280    depending on whether this is a client or server message.281:arg headers: a `.HTTPHeaders` instance.282 283Some `.HTTPConnection` methods can only be called during284``headers_received``.285 286May return a `.Future`; if it does the body will not be read287until it is done.288Nr$)rTr�r�s   rC�headers_received�$HTTPMessageDelegate.headers_received�s��"	
rB�chunkc��g)zYCalled when a chunk of data has been received.289 290May return a `.Future` for flow control.291Nr$�rTr(s  rC�
data_received�!HTTPMessageDelegate.data_received�s��292	
rBc��g)z6Called after the last chunk of data has been received.Nr$r�s rC�finish�HTTPMessageDelegate.finish�rWrBc��g)z�Called if the connection is closed without finishing the request.293 294If ``headers_received`` is called, either ``finish`` or295``on_connection_close`` will be called, but not both.296Nr$r�s rC�on_connection_close�'HTTPMessageDelegate.on_connection_close�r!rBr$r297)r%r&r'r(r)rrNrrr&rr+r.r1rAr$rBrCrr�s]���
��A�B�
��
�298�)�D�/�	"�	
�&
�5�
�X�i��o�-F�
�
�
rBrc	�`�\rSrSrSrSS\SS\S\\SS	4S299jjr	S\SS	4Sjr300SSjrS
rg)r�i�zQApplications use this interface to write their responses.301 302.. versionadded:: 4.0303Nr�r#r�r(rEzFuture[None]c��[5e)a�Write an HTTP header block.304 305:arg start_line: a `.RequestStartLine` or `.ResponseStartLine`.306:arg headers: a `.HTTPHeaders` instance.307:arg chunk: the first (optional) chunk of data.  This is an optimization308    so that small responses can be written in the same call as their309    headers.310 311The ``version`` field of ``start_line`` is ignored.312 313Returns a future for flow control.314 315.. versionchanged:: 6.0316 317   The ``callback`` argument was removed.318r)rTr�r�r(s    rC�
write_headers�HTTPConnection.write_headers�s
��,"�#�#rBc��[5e)z�Writes a chunk of body data.319 320Returns a future for flow control.321 322.. versionchanged:: 6.0323 324   The ``callback`` argument was removed.325rr*s  rC�write�HTTPConnection.write�s
��"�#�#rBc��[5e)z3Indicates that the last body data has been written.rr�s rCr.�HTTPConnection.finishs��!�#�#rBr$rRr326)
r%r&r'r(r)rrNrrr5r8r.rAr$rBrCr�r��sY���"&�	$��A�B�$��$����	$�327328�$�0	$�5�	$�^�	$�$rBr��urlrY.c	���UcU$[U5n[U[5(a4[URSS9nURUR
55 Ou[U[5(d[U[5(a&[URSS9nURU5 O%SR[U55n[U5e[U5n[USUSUSUSUUS45nU$)	a�Concatenate url and arguments regardless of whether329url has existing query parameters.330 331``args`` may be either a dictionary or a list of key-value pairs332(the latter allows for multiple values with the same key.333 334>>> url_concat("http://example.com/foo", dict(c="d"))335'http://example.com/foo?c=d'336>>> url_concat("http://example.com/foo?a=b", dict(c="d"))337'http://example.com/foo?a=b&c=d'338>>> url_concat("http://example.com/foo?a=b", [("c", "d"), ("c", "d2")])339'http://example.com/foo?a=b&c=d&c=d2'340Tr�z7'args' parameter should be dict, list or tuple. Not {0}rr^���)rrc�dictr	r�rr|�list�tuple�format�type�	TypeErrorrr)r<rY�341parsed_url�parsed_query�err�final_querys      rC�342url_concatrK
s���&�|��343��#��J��$���� ��!1�!1�T�J�����D�J�J�L�)�	�D�$�	�	�:�d�E�#:�#:� ��!1�!1�T�J�����D�!�G�N�N���J�344����n���L�)�K�345��q�M��q�M��q�M��q�M���q�M�
	346�	�C��JrBc�8�\rSrSr%Sr\\S'\\S'\\S'Srg)r�i<z�Represents a file uploaded via a form.347 348For backwards compatibility, its instance attributes are also349accessible as dictionary keys.350 351* ``filename``352* ``body``353* ``content_type``354�filenamer��content_typer$N)	r%r&r'r(r)r��__annotations__rrAr$rBrCr�r�<s����M�355�K��rBr��range_headerc�$�URS5upnUR5UR5p1US:wagURS5upBn[U5n[U5nUbUcUS:waU*nSnXg4$US-
nXg4$![a gf=f)aParses a Range header.356 357Returns either ``None`` or tuple ``(start, end)``.358Note that while the HTTP headers use inclusive byte positions,359this method returns indexes suitable for use in slices.360 361>>> start, end = _parse_request_range("bytes=1-2")362>>> start, end363(1, 3)364>>> [0, 1, 2, 3, 4][start:end]365[1, 2]366>>> _parse_request_range("bytes=6-")367(6, None)368>>> _parse_request_range("bytes=-6")369(-6, None)370>>> _parse_request_range("bytes=-0")371(None, 0)372>>> _parse_request_range("bytes=")373(None, None)374>>> _parse_request_range("foo=42")375>>> _parse_request_range("bytes=1-2,6-10")376 377Note: only supports one range (ex, ``bytes=1-2,6-10`` is not allowed).378 379See [0] for the details of the range header.380 381[0]: http://greenbytes.de/tech/webdav/draft-ietf-httpbis-p5-range-latest.html#byte.ranges382rrNrGrr^)r�r��_int_or_noner�)rP�unit�_rk�start_b�end_br��ends        rC�_parse_request_rangerXLs���>"�+�+�C�0�N�D�U��*�*�,����
�%��w�������,��G����W�%���5�!�����=��a�x������
�<��
�1�H�C��<�������s�B�383B�Br�rW�totalc�J�U=(d SnU=(d US-384nSUSUSU3$)z�Returns a suitable Content-Range header:385 386>>> print(_get_content_range(None, 1, 4))387bytes 0-0/4388>>> print(_get_content_range(1, 3, 4))389bytes 1-2/4390>>> print(_get_content_range(None, None, 4))391bytes 0-3/4392rr^zbytes rG�/r$)r�rWrYs   rC�_get_content_ranger\s4��
�J�Q�E��<�%�1�393�C�
�E�7�!�C�5��%��)�)rB�valc�F�UR5nUS:Xag[U5$)Nr�)r�r�)r]s rCrRrR�s ��394
�)�)�+�C�395�b�y���s�8�OrBc�H�\rSrSr%SrSr\\S'Sr\	\S'Sr396\	\S'S	rg397)�ParseMultipartConfigi�z�This class configures the parsing of ``multipart/form-data`` request bodies.398 399Its primary purpose is to place limits on the size and complexity of request messages400to avoid potential denial-of-service attacks.401 402.. versionadded:: 6.5.5403T�enabled�d�	max_partsi(�max_part_header_sizer$N)r%r&r'r(r)rar�rOrcr�rdrAr$rBrCr`r`�s;����G�T����I�s���404!*��#�)�rBr`c�D�\rSrSr%Sr\R"\S9r\\	S'Sr405g)�ParseBodyConfigi�zNThis class configures the parsing of request bodies.406 407.. versionadded:: 6.5.5408)�default_factory�	multipartr$N)r%r&r'r(r)�dataclasses�fieldr`rhrOrAr$rBrCrfrf�s*���409'2�&7�&7�,�'�I�#��DrBrf�configc��Uqg)a�Sets the **global** default configuration for parsing request bodies.410 411This global setting is provided as a stopgap for applications that need to raise the limits412introduced in Tornado 6.5.5, or who wish to disable the parsing of multipart/form-data bodies413entirely. Non-global configuration for this functionality will be introduced in a future414release.415 416>>> content_type = "multipart/form-data; boundary=foo"417>>> multipart_body = b"--foo--\r\n"418>>> parse_body_arguments(content_type, multipart_body, {}, {})419>>> multipart_config = ParseMultipartConfig(enabled=False)420>>> config = ParseBodyConfig(multipart=multipart_config)421>>> set_parse_body_config(config)422>>> parse_body_arguments(content_type, multipart_body, {}, {})423Traceback (most recent call last):424    ...425tornado.httputil.HTTPInputError: ...: multipart/form-data parsing is disabled426>>> set_parse_body_config(ParseBodyConfig())  # reset to defaults427 428.. versionadded:: 6.5.5429N)�_DEFAULT_PARSE_BODY_CONFIG�rks rC�set_parse_body_configro�s430��."(�rBrnrNr�r�r�r�c	�:�Uc[nURS5(amU(aSU;a[SUS-5e[USS9nUR5H/up�U	(dMUR
U/5RU	5 M1 gURS5(a�U(aSU;a[SUS-5eURS	5n431U432S433R5S:wa[S5eU434HTnUR5RS5up�nUS
:XdM-U(dM6[[U5XX5RS9  g [S5eg![an[SU-5UeSnAff=f![an[SU-5UeSnAff=f)a.Parses a form request body.435 436Supports ``application/x-www-form-urlencoded`` and437``multipart/form-data``.  The ``content_type`` parameter should be438a string and ``body`` should be a byte string.  The ``arguments``439and ``files`` parameters are dictionaries that will be updated440with the parsed contents.441Nz!application/x-www-form-urlencodedzContent-Encodingz Unsupported Content-Encoding: %sTr�z&Invalid x-www-form-urlencoded body: %szmultipart/form-data�;rzInvalid content typer�boundaryrnzmultipart boundary not foundzInvalid multipart/form-data: %s)rm�442startswithrorr�r|r�rrIr�r��parse_multipart_form_datarrh)rNr�r�r�r�rk�
uri_arguments�erDr}�fieldsrjrgr�rhs               rCr�r��s���"�~�+�����B�C�C��)�W�4� �2�W�=O�5P�P��
�	V�*�4�4�H�M�*�/�/�1�L�D��v��$�$�T�2�.�5�5�f�=�2�443�	 �	 �!6�	7�	7��)�W�4� �2�W�=O�5P�P��
�	O�!�'�'��,�F��a�y��� �$9�9�$�%;�<�<���!�K�K�M�3�3�C�8�	����444�?�q�q�-��Q���%�@P�@P���
 �%�%C�D�D�%4458���	V� �!I�A�!M�N�TU�U��	V��0�	O� �!B�Q�!F�G�Q�N��	O�sB�446E�AE<�$E<�-E<�

E<�447E9�%E4�4E9�<448F�F�Frr�datac	�R�Uc[RnUR(d[S5eUR	S5(aURS5(aUSSnUR
SU-S-5nUS:Xa[S5eUSURSU-S-5n[U5UR:�a[S	5eUGHZnU(dM
URS4495nUS:Xa[S5eX�R:�a[S5e[RUSURS
5SS9n	U	RSS5n450[!U4515up�US:wdURS5(d[S5eXxS-Sn
URS5(d[S5eUSnURS5(aAU	RSS5nUR#U/5R%['USX�S95 GM9UR#U/5R%U
5 GM] g)aAParses a ``multipart/form-data`` body.452 453The ``boundary`` and ``data`` parameters are both byte strings.454The dictionaries given in the arguments and files parameters455will be updated with the contents of the body.456 457.. versionchanged:: 5.1458 459   Now recognizes non-ASCII filenames in RFC 2231/5987460   (``filename*=``) format.461Nz'multipart/form-data parsing is disabled�"r^r�s--z4Invalid multipart/form-data: no final boundary founds
462z&multipart/form-data has too many partss
463
464z#multipart/form-data missing headersz)multipart/form-data part header too largezutf-8FrizContent-Dispositionr�z	form-datazInvalid multipart/form-data������rDz multipart/form-data missing namerMr�zapplication/unknown)rMr�rN)rmrhrarors�endswith�rfindrIrbrcr�rdrNr��decoderw�
_parse_headerr�rsr�)rrrxr�r�rk�final_boundary_index�parts�part�eohr��disp_header�disposition�disp_paramsrkrD�ctypes                rCrtrts��&�~�+�5�5���>�>��F�G�G����4� � �X�%6�%6�t�%<�%<��A�b�>���:�:�e�h�&6��&>�?���r�!��S�T�T��&�&�'�-�-�e�h�.>��.H�I�E�465�5�z�F�$�$�$��E�F�F������i�i��$���"�9� �!F�G�G��,�,�,� �!L�M�M��#�#�D��#�J�$5�$5�g�$>�QV�#�W���k�k�"7��<��#0��#=� ���+�%�T�]�]�7�-C�-C� �!>�?�?��1�W�r�"�����v�&�&� �!C�D�D��6�"���?�?�:�&�&��K�K��0E�F�E����T�2�&�-�-��(��4�5��
�
� � ��r�*�1�1�%�8�3rB�tsc��[U[[45(aUnO�[U[[R46645(a[R"U5nOR[U[R5(a%[R"UR55nO[SU-5e[RRUSS9$)ayFormats a timestamp in the format used by HTTP.467 468The argument may be a numeric timestamp as returned by `time.time`,469a time tuple as returned by `time.gmtime`, or a `datetime.datetime`470object. Naive `datetime.datetime` objects are assumed to represent471UTC; aware objects are converted to UTC before formatting.472 473>>> format_timestamp(1359312200)474'Sun, 27 Jan 2013 18:43:20 GMT'475zunknown timestamp type: %rT)�usegmt)rcr�rrCr��struct_time�calendar�timegm�datetime�utctimetuplerF�email�utils�476formatdate)r��time_nums  rC�format_timestampr�Xs����"�s�E�l�#�#���	�B��� 0� 0�1�	2�	2��?�?�2�&��	�B��)�)�	*�	*��?�?�2�?�?�#4�5���4�r�9�:�:��;�;�!�!�(�4�!�8�8rBc�4�\rSrSr%\\S'\\S'\\S'Srg)r�ipr9r�r�r$N)r%r&r'r(r�rOrAr$rBrCr�r�ps���K�477
�I�
�LrBr�rc�L�[RRU5nU(d[S5e[	URS5URS5URS55nURRS5(d[SUR-5eU$)z�Returns a (method, path, version) tuple for an HTTP 1.x request line.478 479The response is a `typing.NamedTuple`.480 481>>> parse_request_start_line("GET /foo HTTP/1.1")482RequestStartLine(method='GET', path='/foo', version='HTTP/1.1')483zMalformed HTTP request liner^r>r?�HTTP/1�Unexpected HTTP version %r)rr>rnror��groupr�rs�r�match�rs   rC�parse_request_start_liner�vs���
���(�(��.�E���:�;�;�����Q�����Q�����Q��H�A��9�9����)�)��9�A�I�I�E�F�F��HrBc�4�\rSrSr%\\S'\\S'\\S'Srg)r$i�r��code�reasonr$N)r%r&r'r(r�rOr�rAr$rBrCr$r$�s��
�L�484
�I��KrBr$c�^�[RRU5nU(d[S5e[	URS5[
URS55URS55nURRS5(d[SUR-5eU$)z�Returns a (version, code, reason) tuple for an HTTP 1.x response line.485 486The response is a `typing.NamedTuple`.487 488>>> parse_response_start_line("HTTP/1.1 200 OK")489ResponseStartLine(version='HTTP/1.1', code=200, reason='OK')490z!Error parsing response start liner^r>r?r�r�)	rr@rnror$r�r�r�rsr�s   rC�parse_response_start_liner��s���
���'�'��-�E���@�A�A��%�+�+�a�.�#�e�k�k�!�n�*=�u�{�{�1�~�N�A��9�9����)�)��9�A�I�I�E�F�F��HrB�sc#�# �SnURSU5U:Xa�US-
nURSU5nUSpCUS:�aNX@RSX25URSX25-491-
nUS-S:XaOX0RSUS-5p2US:�aMNUS:a[U5nXUnUR5v� UnURSU5U:XaM�gg7f)Nrrqr^�"z\"r>)r��countrbr�)r�r�rW�ind�diff�fs      rC�_parseparamr��s����
�E�492�&�&��e�493��494%�
��495���f�f�S�%� ���1�T��A�g��G�G�C��*�Q�W�W�U�C�-E�E�E�D��a�x�1�}���F�F�3��a��0��	�A�g�496��7��a�&�C�
�C�L���g�g�i�����&�&��e�497��498%�s�BC�	?C�499Cc�4�[SU-5n[U5nS/nUHnnURS5nUS:�dMUSUR5R	5nXES-SR5nURU[
U545 Mp [RRU5nURS5 0n	UHNupj[RRU5005n[U5S:�aUSS:XaUS	S:XaUSS	nXyU'MP X)4$)501a1Parse a Content-type like header.502 503Return the main content-type and a dictionary of options.504 505>>> d = "form-data; foo=\"b\\\\a\\\"r\"; file*=utf-8''T%C3%A4st"506>>> ct, d = _parse_header(d)507>>> ct508'form-data'509>>> d['file'] == r'T\u00e4st'.encode('ascii').decode('unicode_escape')510True511>>> d['foo']512'b\\a"r'513rq)�DummyrkrrNr^r>r�r�)
r��nextr�r�r�rsr514r�r��
decode_paramsrr�collapse_rfc2231_valuerb)rr��key�params�p�irDrk�decoded_params�pdict�
decoded_values           rCr�r��s
��
��d�515�#�E�516�u�+�C� �
!�F�
��
�F�F�3�K����6��R�a�5�;�;�=�&�&�(�D��!�e�g�J�$�$�&�E��M�M�4��E�!2�3�4���[�[�.�.�v�6�N����q���E�-������2�2�=�A���u�:��?�u�Q�x�3��5��9��3C��!�B�K�E��d��	 .�517�:�rBr�r�c���U(dU$U/n[UR55H1up4UcURU5 MURUSU35 M3 SRU5$)z�Inverse of _parse_header.518 519>>> _encode_header('permessage-deflate',520...     {'client_max_window_bits': 15, 'client_no_context_takeover': None})521'permessage-deflate; client_max_window_bits=15; client_no_context_takeover'522rz; )�sortedr|rsrH)r�r��outrgrhs     rC�_encode_headerr��sb����523��%�C��u�{�{�}�%����9��J�J�q�M�
�J�J�!��A�a�S�z�"�&��9�9�S�>�rB�username�passwordc���[U[5(a[R"SU5n[U[5(a[R"SU5n[	U5S-[	U5-$)z�Encodes a username/password pair in the format used by HTTP auth.524 525The return value is a byte string in the form ``username:password``.526 527.. versionadded:: 5.1528�NFC�:)rcr�unicodedata�	normalizer)r�r�s  rC�encode_username_passwordr��sZ���(�L�)�)��(�(���9���(�L�)�)��(�(���9����>�D� �4��>�1�1rBc�<�SSKnURURS9$)Nr)�optionflags)�doctest�DocTestSuite�ELLIPSIS)r�s rC�doctestsr�s������G�,<�,<��=�=rBz^(.+):(\d+)$�netlocc��[RU5nU(a.URS5n[URS55nX#4$UnSnX#4$)z{Returns ``(host, port)`` tuple from ``netloc``.529 530Returned ``port`` will be ``None`` if not present.531 532.. versionadded:: 4.1533r^r>N)�534_netloc_rer�r�r�)r�r�r:�ports    rCr�r�sT��
���V�$�E���{�{�1�~���5�;�;�q�>�"��
�<�������<�rB�qsc#�Z# �UR5HupUHnX4v� M535 M g7f)z_Generator converting a result of ``parse_qs`` back to name-value pairs.536 537.. versionadded:: 5.0538N)r|)r�rg�vsrhs    rC�	qs_to_qslr�*s*���539�������A��&�L���s�)+z\\(?:([0-3][0-7][0-7])|(.))r�c�P�US(a[[USS55$US$)Nr^�r>)�chrr�)r�s rC�_unquote_replacer�7s'����t��3�q��t�Q�<� � ���t�rBc�|�Ub[U5S:aU$USS:wd	USS:waU$USSn[[U5$)z�Handle double quotes and escaping in cookie values.540 541This method is copied verbatim from the Python 3.13 standard542library (http.cookies._unquote) so we don't have to depend on543non-public interfaces.544r>rr�r�r^)rb�_unquote_subr�)r�s rC�_unquote_cookier�>sO��	�y�C��F�Q�J�����t�s�{�a��e�s�l���	545�!�B��A��(�!�,�,rB�cookiec���0nURS5H]nSU;aURSS5up4OSUpCUR5UR5pCU(d	U(dMP[U5X'M_ U$)aCParse a ``Cookie`` HTTP header into a dict of name/value pairs.546 547This function attempts to mimic browser cookie parsing behavior;548it specifically does not follow any of the cookie-related RFCs549(because browsers don't either).550 551The algorithm used is identical to that used by Django version 1.9.10.552 553.. versionadded:: 4.4.2554rqrr^r�)rIr�r�)r��555cookiedictr(r�r]s     rCr�r�Ysn���J����c�"���%�<��{�{�3��*�H�C���5���9�9�;��	�	��S��#�#�-�c�2�J�O�#��rBrR)hr)r��collections.abc�collectionsr�rir��email.utilsr��	functoolsr�http.clientr�http.cookiesr�r*�sslrr�r��urllib.parserrrr	�tornado.escaper556rrr
�tornado.utilrrr�rrrrrrrrrrr�
TYPE_CHECKINGr�asyncior�unittest�abc�MutableMappingr��StrMutableMappingr�r+rprrLrNr�r�rorrrr�rKr�r�rXr\rR�	dataclassr`rfrmrorr�rtrrCr�r��557NamedTupler�r�r$r�r�r�r�r�r�r�r�r��subr��Matchr�r�r�r$rBrC�<module>r�s-�� ��������!��	����C�C�G�G�1�558559�
�����560������$���6�6�s�C�x�@��#���6�6���� �Z�Z�(C�D��5�5�p�4��?�C�?�C�?��?�o�#�o�d{4�{4�|	�Y�	�	�i�	�
�
�:+
�+
�\+$�+$�\,�	�,�561��d�3��8�n�d�5��c��?�3�U�5��c��?�C�;O�5P�P��,�562	�,�^
�z�
� 0��0�
�e�H�S�M�8�C�=�0�1�2�0�f*�h�s�m�*�(�3�-�*��*�PS�*��c��h�s�m��
�������B
���	D�	D��	D�-�.��(�/�(�d�(�>&*�4O�)-�4O��4O�563�4O��C��e��$�%�4O���T�(�^�#�$�	4O�564�k�
"�4O�
�_�%�4O�565�4O�z.2�
=9��=9�566�=9��C��e��$�%�=9���T�(�^�#�$�	=9�
�)�*�
=9�567�=9�@9�
�c�5�%��!1�!1�8�3D�3D�D�E�9��9�0�v�(�(��
�3�
�+;�
�,��)�)��
�C�
�,=�
�H�3��9�S�$��_�5��$ �� ��c�4��S��>�&9� :� �F���D��c��N��s��(
2��C��J��
2�+0��e��+<�
2�568�
2� >��Z�Z��
(�569�����c�8�C�=�.@�(A��"�$�s�D��L�(�)��h�u�S�&�[�7I�.J���z�z�8�9�=�=�������S��-�s�-�s�-�6����c�3�h��rB
codekingpro/portable-devtools · Team Ai