Team Ai
Datasetpublic

codekingpro/portable-devtools

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

2��jy��R�SrSSKrSSKrSSKJr SSKrSSKrSSKrSSKJ	r	J3r4Jr SSKJ
r
Jr SSKJrJr SSKJr SSKJr SS	KJrJrJrJrJrJrJr "S5S5r"SS
\5r"SS5r "SS5r!"SS\"5r#\#r$"SS5r%SSjr&\'S:Xa\&"5 gg)a�Blocking and non-blocking HTTP client interfaces.6 7This module defines a common interface shared by two implementations,8``simple_httpclient`` and ``curl_httpclient``.  Applications may either9instantiate their chosen implementation class directly or use the10`AsyncHTTPClient` class from this module, which selects an implementation11that can be overridden with the `AsyncHTTPClient.configure` method.12 13The default implementation is ``simple_httpclient``, and this is expected14to be suitable for most users' needs.  However, some applications may wish15to switch to ``curl_httpclient`` for reasons such as the following:16 17* ``curl_httpclient`` has some features not found in ``simple_httpclient``,18  including support for HTTP proxies and the ability to use a specified19  network interface.20 21* ``curl_httpclient`` is more likely to be compatible with sites that are22  not-quite-compliant with the HTTP spec, or sites that use little-exercised23  features of HTTP.24 25* ``curl_httpclient`` is faster.26 27Note that if you are using ``curl_httpclient``, it is highly28recommended that you use a recent version of ``libcurl`` and29``pycurl``.  Currently the minimum supported version of libcurl is307.22.0, and the minimum version of pycurl is 7.18.2.  It is highly31recommended that your ``libcurl`` installation is built with32asynchronous DNS resolver (threaded or c-ares), otherwise you may33encounter various problems with request timeouts (for more34information, see35http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTCONNECTTIMEOUTMS36and comments in curl_httpclient.py).37 38To select ``curl_httpclient``, call `AsyncHTTPClient.configure` at startup::39 40    AsyncHTTPClient.configure("tornado.curl_httpclient.CurlAsyncHTTPClient")41�N)�BytesIO)�Future�"future_set_result_unless_cancelled�%future_set_exception_unless_cancelled)�utf8�42native_str)�gen�httputil)�IOLoop)�Configurable)�Type�Any�Union�Dict�Callable�Optional�castc�h�\rSrSrSrSSSS\SS4SjjrSS	jrSS43jrS\	S\444S\SS
4SjrSrg)�45HTTPClient�;a�A blocking HTTP client.46 47This interface is provided to make it easier to share code between48synchronous and asynchronous applications. Applications that are49running an `.IOLoop` must use `AsyncHTTPClient` instead.50 51Typical usage looks like this::52 53    http_client = httpclient.HTTPClient()54    try:55        response = http_client.fetch("http://www.google.com/")56        print(response.body)57    except httpclient.HTTPError as e:58        # HTTPError is raised for non-200 responses; the response59        # can be found in e.response.60        print("Error: " + str(e))61    except Exception as e:62        # Other errors are possible, such as IOError.63        print("Error: " + str(e))64    http_client.close()65 66.. versionchanged:: 5.067 68   Due to limitations in `asyncio`, it is no longer possible to69   use the synchronous ``HTTPClient`` while an `.IOLoop` is running.70   Use `AsyncHTTPClient` instead.71 72N�async_client_classzOptional[Type[AsyncHTTPClient]]�kwargs�returnc�^^�SUl[SS9UlTc[mSUU4SjjnURR	U5UlSUlg)NTF)�make_currentc��f># �[R"S5IShv�N TceT"S0TD6$N7f)Nr�)r	�sleep)rrs���XD:\code\apps\devtools\python\user_packages\Python313\site-packages\tornado/httpclient.py�make_client�(HTTPClient.__init__.<locals>.make_clienths6�����)�)�A�,���%�1�1�1�%�/��/�/�
�s�1�/�1)r�AsyncHTTPClient)�_closedr�_io_loopr"�run_sync�
_async_client)�selfrrr s `` r�__init__�HTTPClient.__init__YsN�������E�2��
��%�!0��	0�	0�73"�]�]�3�3�K�@������c�$�UR5 g�N)�close�r's r�__del__�HTTPClient.__del__ps���74�75�r*c��UR(d<URR5 URR5 SUlgg)z2Closes the HTTPClient, freeing any resources used.TN)r#r&r-r$r.s rr-�HTTPClient.closess7���|�|����$�$�&��M�M���!��D�L�r*�request�HTTPRequest�HTTPResponsec��URR[R"URR76U40UD65nU$)aaExecutes a request, returning an `HTTPResponse`.77 78The request may be either a string URL or an `HTTPRequest` object.79If it is a string, we construct an `HTTPRequest` using any additional80kwargs: ``HTTPRequest(request, **kwargs)``81 82If an error occurs during the fetch, we raise an `HTTPError` unless83the ``raise_error`` keyword argument is set to False.84)r$r%�	functools�partialr&�fetch)r'r3r�responses    rr9�HTTPClient.fetchzs@���=�=�)�)����d�0�0�6�6��J�6�J�85���r*)r&r#r$r,�rN)
�__name__�86__module__�__qualname__�__firstlineno__�__doc__rr(r/r-r�strr9�__static_attributes__rr*rrr;s`���>AE��=����87�	�.� ���]�C�/�0��<?��	�r*rc	�D^�\rSrSrSrSr\S\\4Sj5r	\S\\4Sj5r88\S\\S44Sj5r
SS\S	\SS4U4S89jjjrSS\\\\4SS4SjjrSS
jrSS\\S4S\S	\SS4SjjrSSS\S/S4SS4Sjr\SSS	\SS4U4Sjj5rSrU=r$)r"�a$An non-blocking HTTP client.90 91Example usage::92 93    async def f():94        http_client = AsyncHTTPClient()95        try:96            response = await http_client.fetch("http://www.google.com")97        except Exception as e:98            print("Error: %s" % e)99        else:100            print(response.body)101 102The constructor for this class is magic in several respects: It103actually creates an instance of an implementation-specific104subclass, and instances are reused as a kind of pseudo-singleton105(one per `.IOLoop`). The keyword argument ``force_instance=True``106can be used to suppress this singleton behavior. Unless107``force_instance=True`` is used, no arguments should be passed to108the `AsyncHTTPClient` constructor. The implementation subclass as109well as arguments to its constructor can be set with the static110method `configure()`111 112All `AsyncHTTPClient` implementations support a ``defaults``113keyword argument, which can be used to set default values for114`HTTPRequest` attributes.  For example::115 116    AsyncHTTPClient.configure(117        None, defaults=dict(user_agent="MyUserAgent"))118    # or with force_instance:119    client = AsyncHTTPClient(force_instance=True,120        defaults=dict(user_agent="MyUserAgent"))121 122.. versionchanged:: 5.0123   The ``io_loop`` argument (deprecated since version 4.1) has been removed.124 125Nrc��[$r,)r")�clss r�configurable_base�!AsyncHTTPClient.configurable_base�s���r*c��SSKJn U$)Nr)�SimpleAsyncHTTPClient)�tornado.simple_httpclientrK)rGrKs  r�configurable_default�$AsyncHTTPClient.configurable_default�s��C�$�$r*c��SUR-n[X5(d[X[R"55 [X5$)N�_async_client_dict_)r=�hasattr�setattr�weakref�WeakKeyDictionary�getattr)rG�	attr_names  r�_async_clients�AsyncHTTPClient._async_clients�s9��)�C�L�L�8�	��s�&�&��C�G�$=�$=�$?�@��s�&�&r*�force_instancerc��>�[R"5nU(aSnOUR5nUb	X4;aXC$[TU]"U40UD6nXElUbXTUR'U$r,)r�currentrW�super�__new__�_instance_cache�io_loop)rGrYrr_�instance_cache�instance�	__class__s      �rr]�AsyncHTTPClient.__new__�sm����.�.�"���!�N� �/�/�1�N��%�'�*C�!�*�*��7�?�3�1�&�1��126$2� ��%�/7�8�+�+�,��r*�defaultsc��[R"5Ul[[R1275UlUbURRU5 SUlg)NF)	rr[r_�dictr4�	_DEFAULTSrd�updater#)r'rds  r�128initialize�AsyncHTTPClient.initialize�sA���~�~�'����[�2�2�3��
����M�M� � ��*���r*c���UR(agSUlURb:URRURS5nUbXLa[	S5eggg)a�Destroys this HTTP client, freeing any file descriptors used.129 130This method is **not needed in normal use** due to the way131that `AsyncHTTPClient` objects are transparently reused.132``close()`` is generally only necessary when either the133`.IOLoop` is also being closed, or the ``force_instance=True``134argument was used when creating the `AsyncHTTPClient`.135 136No other methods may be called on the `AsyncHTTPClient` after137``close()``.138 139NTz"inconsistent AsyncHTTPClient cache)r#r^�popr_�RuntimeError)r'�140cached_vals  rr-�AsyncHTTPClient.close�sd���<�<��������+��-�-�1�1�$�,�,��E�J��%�*�*@�"�#G�H�H�+A�%�,r*r3r4�raise_errorzFuture[HTTPResponse]c�^^�UR(a[S5e[U[5(d[SSU0UD6nOU(a[	S5e[141R"UR5Ul[XR5n[5mSUU4SjjnUR[[U5U5 T$)aRExecutes a request, asynchronously returning an `HTTPResponse`.142 143The request may be either a string URL or an `HTTPRequest` object.144If it is a string, we construct an `HTTPRequest` using any additional145kwargs: ``HTTPRequest(request, **kwargs)``146 147This method returns a `.Future` whose result is an148`HTTPResponse`. By default, the ``Future`` will raise an149`HTTPError` if the request returned a non-200 response code150(other errors may also be raised if the server could not be151contacted). Instead, if ``raise_error`` is set to False, the152response will always be returned regardless of the response153code.154 155If a ``callback`` is given, it will be invoked with the `HTTPResponse`.156In the callback interface, `HTTPError` is not automatically raised.157Instead, you must check the response's ``error`` attribute or158call its `~HTTPResponse.rethrow` method.159 160.. versionchanged:: 6.0161 162   The ``callback`` argument was removed. Use the returned163   `.Future` instead.164 165   The ``raise_error=False`` argument only affects the166   `HTTPError` raised when a non-200 response code is used,167   instead of suppressing all errors.168z(fetch() called on closed AsyncHTTPClient�urlz8kwargs can't be used if request is an HTTPRequest objectc�>�UR(a/T(dUR(d[TUR5 g[TU5 gr,)�error�_error_is_response_coderr)r:�futurerps ��r�handle_response�.AsyncHTTPClient.fetch.<locals>.handle_response+s0����~�~��h�&F�&F�9�&�(�.�.�Q��.�v�x�@r*r)r:r5rN)
r#rm�169isinstancer4�170ValueErrorr171�HTTPHeaders�headers�
_RequestProxyrdr�172fetch_implr)r'r3rpr�
request_proxyrwrvs  `   @rr9�AsyncHTTPClient.fetch�s����D�<�<��I�J�J��'�;�/�/�!�8�g�8��8�G�� �N���#�.�.�w���?���%�g�}�}�=�
����	A�	A�	
����[�-�8�/�J��
r*�callbackr5c��[5er,)�NotImplementedError)r'r3r�s   rr~�AsyncHTTPClient.fetch_impl5s
��"�#�#r*�implz$Union[None, str, Type[Configurable]]c�(>�[TU]"U40UD6 g)a�Configures the `AsyncHTTPClient` subclass to use.173 174``AsyncHTTPClient()`` actually creates an instance of a subclass.175This method may be called with either a class object or the176fully-qualified name of such a class (or ``None`` to use the default,177``SimpleAsyncHTTPClient``)178 179If additional keyword arguments are given, they will be passed180to the constructor of each subclass instance created.  The181keyword argument ``max_clients`` determines the maximum number182of simultaneous `~AsyncHTTPClient.fetch()` operations that can183execute in parallel on each `.IOLoop`.  Additional arguments184may be supported depending on the implementation class in use.185 186Example::187 188   AsyncHTTPClient.configure("tornado.curl_httpclient.CurlAsyncHTTPClient")189N)r\�	configure)rGr�rrbs   �rr��AsyncHTTPClient.configure:s���,	���$�)�&�)r*)r#rdr_)Fr,r<)T)r=r>r?r@rAr^�classmethodr
rrHrMrrrW�boolrr]rrBrir-rr9rr~r�rC�
__classcell__�rbs@rr"r"�sK���$�L�O���$�|�"4�����%�T�,�%7�%��%�190�'�t�F�,=�$=�>�'��'��T��S��EV���$�8�D��c��N�#;��t��I�:!�:��s�M�)�*�:��:��	:�191192 �:�x$�$�$�08�.�9I�4�9O�0P�$�	
�$�193�*�9�*�EH�*�	
�*��*r*r"cG�J�\rSrSrSrSr\"SSSSSSSSS	9rS4S194\S\S\	\195\\\4\R4S
\	\196\\4S\	\S\	\S\	\S\	\S\	\S\	\197\\R 4S\	\S\	\S\	\S\	\S\	\S\	\\/S4S\	\\/S4S\	\\/S4S\	\S\	\S\	\S\	\S \	\S!\	\S"\	\S#\	\S$\	\S%\	\S&\	\S'\	\\\/S4/S(4S)\S*\	\S+\	\198\\\4\R,4S,S4DS-jjr\S,\R4S.j5r\R4S/\199\\\4\R4S,S4S0j5r\S,\4S1j5r\R4S/\200\\4S,S4S2j5rS3rg)5r4iSzHTTP client request object.Ng4@T��F)�connect_timeout�request_timeout�follow_redirects�
max_redirects�decompress_response�proxy_password�allow_nonstandard_methods�
validate_certrr�methodr|�body�
auth_username�
auth_password�	auth_moder�r��if_modified_sincer�r��201user_agent�use_gzip�network_interface�streaming_callback�header_callback�prepare_curl_callback�202proxy_host�203proxy_port�proxy_usernamer��proxy_auth_moder�r��ca_certs�204allow_ipv6�205client_key�client_cert�
body_producerzFuture[None]�expect_100_continuer��ssl_optionsrc"�8�X0lU206(a#[R"U2075URS'UUlUUlUUlUUlUUlXlX l	X@l208UUlXPlX`l
XplX�lX�lX�lX�lX�lU bU UlOX�lX�lUUlUUlUUlUUlUUlUUlUUlUUlUUlU!UlUUl [BRB"5Ul"g)a�All parameters except ``url`` are optional.209 210:arg str url: URL to fetch211:arg str method: HTTP method, e.g. "GET" or "POST"212:arg headers: Additional HTTP headers to pass on the request213:type headers: `~tornado.httputil.HTTPHeaders` or `dict`214:arg body: HTTP request body as a string (byte or unicode; if unicode215   the utf-8 encoding will be used)216:type body: `str` or `bytes`217:arg collections.abc.Callable body_producer: Callable used for218   lazy/asynchronous request bodies.219   It is called with one argument, a ``write`` function, and should220   return a `.Future`.  It should call the write function with new221   data as it becomes available.  The write function returns a222   `.Future` which can be used for flow control.223   Only one of ``body`` and ``body_producer`` may224   be specified.  ``body_producer`` is not supported on225   ``curl_httpclient``.  When using ``body_producer`` it is recommended226   to pass a ``Content-Length`` in the headers as otherwise chunked227   encoding will be used, and many servers do not support chunked228   encoding on requests.  New in Tornado 4.0229:arg str auth_username: Username for HTTP authentication230:arg str auth_password: Password for HTTP authentication231:arg str auth_mode: Authentication mode; default is "basic".232   Allowed values are implementation-defined; ``curl_httpclient``233   supports "basic" and "digest"; ``simple_httpclient`` only supports234   "basic"235:arg float connect_timeout: Timeout for initial connection in seconds,236   default 20 seconds (0 means no timeout)237:arg float request_timeout: Timeout for entire request in seconds,238   default 20 seconds (0 means no timeout)239:arg if_modified_since: Timestamp for ``If-Modified-Since`` header240:type if_modified_since: `datetime` or `float`241:arg bool follow_redirects: Should redirects be followed automatically242   or return the 3xx response? Default True.243:arg int max_redirects: Limit for ``follow_redirects``, default 5.244:arg str user_agent: String to send as ``User-Agent`` header245:arg bool decompress_response: Request a compressed response from246   the server and decompress it after downloading.  Default is True.247   New in Tornado 4.0.248:arg bool use_gzip: Deprecated alias for ``decompress_response``249   since Tornado 4.0.250:arg str network_interface: Network interface or source IP to use for request.251   See ``curl_httpclient`` note below.252:arg collections.abc.Callable streaming_callback: If set, ``streaming_callback`` will253   be run with each chunk of data as it is received, and254   ``HTTPResponse.body`` and ``HTTPResponse.buffer`` will be empty in255   the final response.256:arg collections.abc.Callable header_callback: If set, ``header_callback`` will257   be run with each header line as it is received (including the258   first line, e.g. ``HTTP/1.0 200 OK\r\n``, and a final line259   containing only ``\r\n``.  All lines include the trailing newline260   characters).  ``HTTPResponse.headers`` will be empty in the final261   response.  This is most useful in conjunction with262   ``streaming_callback``, because it's the only way to get access to263   header data while the request is in progress.264:arg collections.abc.Callable prepare_curl_callback: If set, will be called with265   a ``pycurl.Curl`` object to allow the application to make additional266   ``setopt`` calls.267:arg str proxy_host: HTTP proxy hostname.  To use proxies,268   ``proxy_host`` and ``proxy_port`` must be set; ``proxy_username``,269   ``proxy_pass`` and ``proxy_auth_mode`` are optional.  Proxies are270   currently only supported with ``curl_httpclient``.271:arg int proxy_port: HTTP proxy port272:arg str proxy_username: HTTP proxy username273:arg str proxy_password: HTTP proxy password274:arg str proxy_auth_mode: HTTP proxy Authentication mode;275   default is "basic". supports "basic" and "digest"276:arg bool allow_nonstandard_methods: Allow unknown values for ``method``277   argument? Default is False.278:arg bool validate_cert: For HTTPS requests, validate the server's279   certificate? Default is True.280:arg str ca_certs: filename of CA certificates in PEM format,281   or None to use defaults.  See note below when used with282   ``curl_httpclient``.283:arg str client_key: Filename for client SSL key, if any.  See284   note below when used with ``curl_httpclient``.285:arg str client_cert: Filename for client SSL certificate, if any.286   See note below when used with ``curl_httpclient``.287:arg ssl.SSLContext ssl_options: `ssl.SSLContext` object for use in288   ``simple_httpclient`` (unsupported by ``curl_httpclient``).289   Overrides ``validate_cert``, ``ca_certs``, ``client_key``,290   and ``client_cert``.291:arg bool allow_ipv6: Use IPv6 when available?  Default is True.292:arg bool expect_100_continue: If true, send the293   ``Expect: 100-continue`` header and wait for a continue response294   before sending the request body.  Only supported with295   ``simple_httpclient``.296 297.. note::298 299    When using ``curl_httpclient`` certain options may be300    inherited by subsequent fetches because ``pycurl`` does301    not allow them to be cleanly reset.  This applies to the302    ``ca_certs``, ``client_key``, ``client_cert``, and303    ``network_interface`` arguments.  If you use these304    options, you should pass them on every request (you don't305    have to always use the same values, but it's not possible306    to mix requests that specify these options with ones that307    use the defaults).308 309.. versionadded:: 3.1310   The ``auth_mode`` argument.311 312.. versionadded:: 4.0313   The ``body_producer`` and ``expect_100_continue`` arguments.314 315.. versionadded:: 4.2316   The ``ssl_options`` argument.317 318.. versionadded:: 4.5319   The ``proxy_auth_mode`` argument.320zIf-Modified-SinceN)#r|r321�format_timestampr�r�r�r�r�rrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��time�322start_time)"r'rrr�r|r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�s"                                  rr(�HTTPRequest.__init__fs��r���08�0I�0I�!�1�D�L�L�,�-�%���$���,���,���.��������	�*���*��*��"��.��.�� 0��*��$���*�':�D�$�'/�$�!2��"4���.���%:��"�)B��&�*��� ��
�$���$���&���&���#6�� ��)�)�+��r*c��UR$r,)�_headersr.s rr|�HTTPRequest.headers's��323�}�}�r*�valuec�L�Uc"5UlgXlgr,)r324r{r��r'r�s  rr|r�.s���=�$�0�0�2�D�M�!�Mr*c��UR$r,)�_bodyr.s rr��HTTPRequest.body5s���z�z�r*c�$�[U5Ulgr,)rr�r�s  rr�r�9s
���%�[��325r*)"r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r|r�r�r�r�r�r�r�r�r�r�r�r�r�rrr�r�) �GETNNNNNNNNNNNNNNNNNNNNNNNNNNNNFNN)r=r>r?r@rAr�rfrgrBrrrr326r{�bytes�float�datetimer��intrr�ssl�327SSLContextr(�propertyr|�setterr�rCrr*rr4r4Ss���%��H�328����� ��"'��	�I��IM�,0�'+�'+�#'�+/�+/�GK�+/�'+�$(�#'�+/�@D�;?�AE�$(�$(�(,�(,�)-�48�(,�"&�%)�$(�%)�
�$)�.2�GK�I&�
�&��&��%��S�#�X���0D�0D� D�E�F�	&�329�u�U�C�Z�(�)�&� ��}�
&� ��}�&��C�=�&�"�%��&�"�%��&�$�E�%��1B�1B�*B�$C�D�&�#�4�.�&� ��}�&��S�M�&��4�.�&� $�C�=�!&�"%�X�u�g�t�m�%<�=�#&�$"�(�C�5�$�;�"7�8�%&�& (��#����(=�>�'&�(�S�M�)&�*�S�M�+&�,!��
�-&�.!��
�/&�0"�#��1&�2$,�D�>�3&�4 ��~�5&�6�3�-�7&�8�T�N�9&�:�S�M�;&�<�c�]�=&�> ��h��w��}�-�.��>�?�330�?&�D"�E&�F&�d�^�G&�H�e�D��c��N�C�N�N�$B�C�D�I&�J331�K&�B���-�-����
�^�^�"�U�4��S��>�8�3G�3G�#G�H�"�T�"��"���e����332�[�[�!�%��s�333�+�!��!��!r*r4c���\rSrSrSrSrSrSrSS\S\	S\334\RS\335\
S	\336\S337\338\S\339\S\340\\\4S
\341\S\342\SS4Sjjr\S\4Sj5rSSjrS\4SjrSrg)r5i>a�HTTP Response object.343 344Attributes:345 346* ``request``: HTTPRequest object347 348* ``code``: numeric HTTP status code, e.g. 200 or 404349 350* ``reason``: human-readable reason phrase describing the status code351 352* ``headers``: `tornado.httputil.HTTPHeaders` object353 354* ``effective_url``: final location of the resource after following any355  redirects356 357* ``buffer``: ``cStringIO`` object for response body358 359* ``body``: response body as bytes (created on demand from ``self.buffer``)360 361* ``error``: Exception object, if any362 363* ``request_time``: seconds from request start to finish. Includes all364  network operations from DNS resolution to receiving the last byte of365  data. Does not include time spent in the queue (due to the366  ``max_clients`` option). If redirects were followed, only includes367  the final request.368 369* ``start_time``: Time at which the HTTP operation started, based on370  `time.time` (not the monotonic clock used by `.IOLoop.time`). May371  be ``None`` if the request timed out while in the queue.372 373* ``time_info``: dictionary of diagnostic timing information from the374  request. Available data are subject to change, but currently uses timings375  available from http://curl.haxx.se/libcurl/c/curl_easy_getinfo.html,376  plus ``queue``, which is the delay (if any) introduced by waiting for377  a slot under `AsyncHTTPClient`'s ``max_clients`` setting.378 379.. versionadded:: 5.1380 381   Added the ``start_time`` attribute.382 383.. versionchanged:: 5.1384 385   The ``request_time`` attribute previously included time spent in the queue386   for ``simple_httpclient``, but not in ``curl_httpclient``. Now queueing time387   is excluded in both implementations. ``request_time`` is now more accurate for388   ``curl_httpclient`` because it uses a monotonic clock when available.389NFr3�coder|�buffer�
effective_urlrt�request_time�	time_info�reasonr�rc�^�[U[5(aURUlOXlX lU	=(d  [R390R
US5UlUbX0lO[R"5UlX@l391SUlUcURUl
OXPl
SUlUcTURS:dURS:�a,SUl[URURUS9UlOSUlOX`lX�lXplU=(d 0Ulg)N�UnknownF��i,T)�messager:)ryr}r3r�r392�	responses�getr�r|r{r�r�rrr�ru�	HTTPErrorrtr�r�r�)r'r3r�r|r�r�rtr�r�r�r�s           rr(�HTTPResponse.__init__us����g�}�-�-�"�?�?�D�L�"�L��	��G�� 2� 2� 6� 6�t�Y� G�����"�L�#�/�/�1�D�L�����393�� �!(���D��!.��',��$��=��y�y�3��$�)�)�s�"2�/3��,�&�t�y�y�$�+�+�PT�U��394�!��395��J�$��(��"��b��r*c��URcgURcURR5UlUR$)Nr*)r�r��getvaluer.s rr��HTTPResponse.body�s7���;�;���
�Z�Z�
����-�-�/�D�J��z�z�r*c�>�UR(aUReg)z;If there was an error on the request, raise an `HTTPError`.N)rtr.s r�rethrow�HTTPResponse.rethrow�s���:�:��*�*��r*c��SRS[URR5555nURR396SUS3$)N�,c3�,# �UH397nSU-v� M g7f)z%s=%rNr)�.0�is  r�	<genexpr>�(HTTPResponse.__repr__.<locals>.<genexpr>�s���K�-J���!��-J�s��(�))�join�sorted�__dict__�itemsrbr=)r'�argss  r�__repr__�HTTPResponse.__repr__�sF���x�x�K�V�D�M�M�4G�4G�4I�-J�K�K���.�.�)�)�*�!�D�6��3�3r*)r�rur�r�r�rtr|r�r3r�r�r�)NNNNNNNNr<)r=r>r?r@rArtrur3r4r�rr398r{rrB�
BaseExceptionr�rr(r�r�r�r�r�rCrr*rr5r5>s��/�d
�E�#���G�37�$(�'+�)-�(,�04� $�&*�()��()��()��(�.�.�/�	()�399��!�()� ��}�
()��
�&�()��u�o�()��D��e��,�-�()���
�()��U�O�()�400�()�T��e�����4014�#�4r*r5c	�f^�\rSrSrSrSS\S\\S\\SS4U4Sjjjr	S\4S	jr402\403rS404rU=r
$)�HTTPClientErrori�amException thrown for an unsuccessful HTTP request.405 406Attributes:407 408* ``code`` - HTTP error integer error code, e.g. 404.  Error code 599 is409  used when no HTTP response was received, e.g. for a timeout.410 411* ``response`` - `HTTPResponse` object, if any.412 413Note that if ``follow_redirects`` is False, redirects become HTTPErrors,414and you can look at ``error.response.headers['Location']`` to see the415destination of the redirect.416 417.. versionchanged:: 5.1418 419   Renamed from ``HTTPError`` to ``HTTPClientError`` to avoid collisions with420   `tornado.web.HTTPError`. The name ``tornado.httpclient.HTTPError`` remains421   as an alias.422Nr�r�r:rc�>�XlU=(d  [RRUS5UlX0l[TU]XU5 g)Nr�)r�r423r�r�r�r:r\r()r'r�r�r:rbs    �rr(�HTTPClientError.__init__�s=����	��I�(�"4�"4�"8�"8��y�"I��� �
�
�����1r*c�8�SURUR4-$)NzHTTP %d: %s)r�r�r.s r�__str__�HTTPClientError.__str__�s����	�	�4�<�<�8�8�8r*)r�r�r:)NN)r=r>r?r@rAr�rrBr5r(r�r�rCr�r�s@rr�r��s\����."&�+/�		2��	2��#��	2��<�(�		2�424425�	2�	2�9��9��Hr*r�c�P�\rSrSrSrS\S\\\\	4SS4Sjr426S\S\	4S	jrS427rg)r}i�zgCombines an object with a dictionary of defaults.428 429Used internally by AsyncHTTPClient implementations.430r3rdrNc��XlX lgr,)r3rd)r'r3rds   rr(�_RequestProxy.__init__�s���� �
r*�namec��[URU5nUbU$URbURRUS5$gr,)rUr3rdr�)r'r��request_attrs   r�__getattr__�_RequestProxy.__getattr__�sB���t�|�|�T�2���#���
�]�]�
&��=�=�$�$�T�4�0�0�r*)rdr3)
r=r>r?r@rAr4rrrBrr(r�rCrr*rr}r}�sD���431!�"�!�.6�t�C��H�~�.F�!�	
�!�����r*r}c	��SSKJnJnJn U"S[SS9 U"S[SS9 U"S[SS9 U"S	[SS9 U"S432[433S9 U"S[S9 U"5n[5nUH�nURUURURURURS
9nUR(a[!UR"5 UR$(dMx[!['UR(55 M� UR+5 g![a$nURbURnSnAN�eSnAff=f)Nr)�define�options�parse_command_line�
print_headersF)�type�default�434print_bodyTr�r�r�)rr�)r�r�r�r�)�tornado.optionsr�r�r�r�rBr�rr9r�r�r�r�r�r:r�printr|rrr�r-)r�r�r�r��client�argr:�es        r�mainr	�s��C�C�435�?��u�5�436�<�d�D�1�437��D�$�7�438�?��t�4�439�<�c�"�440�<�c�"���D�
�\�F���	��|�|��!(�!9�!9�%�3�3�"�-�-�"�-�-�$��H�� � ��(�"�"�#������*�X�]�]�+�,�#�$�L�L�N���	��z�z�%��:�:����		�s�(;D�441D=�D8�7D8�8D=�__main__r<)(rAr�r7�iorr�r�rS�tornado.concurrentrrr�tornado.escaperr�tornador	r442�tornado.ioloopr�tornado.utilr�typingr
rrrrrrrr"r4r5�	Exceptionr�r�r}r	r=rr*r�<module>rs���$�L���443�����444,�!�!�%�C�C�C�N�N�bD*�l�D*�Nh!�h!�Vq4�q4�h'�i�'�T
�	���,�@�z���F�r*
codekingpro/portable-devtools · Team Ai