golden hour
/opt/saltstack/salt/lib/python3.10/site-packages/salt/ext/tornado/__pycache__
⬆️ Go Up
Upload
File/Folder
Size
Actions
__init__.cpython-310.pyc
378 B
Del
OK
_locale_data.cpython-310.pyc
3.23 KB
Del
OK
auth.cpython-310.pyc
39.18 KB
Del
OK
autoreload.cpython-310.pyc
7.02 KB
Del
OK
concurrent.cpython-310.pyc
17.24 KB
Del
OK
curl_httpclient.cpython-310.pyc
12.8 KB
Del
OK
escape.cpython-310.pyc
9.89 KB
Del
OK
gen.cpython-310.pyc
38.39 KB
Del
OK
http1connection.cpython-310.pyc
19.47 KB
Del
OK
httpclient.cpython-310.pyc
25.19 KB
Del
OK
httpserver.cpython-310.pyc
11.45 KB
Del
OK
httputil.cpython-310.pyc
29.84 KB
Del
OK
ioloop.cpython-310.pyc
33.19 KB
Del
OK
iostream.cpython-310.pyc
42.97 KB
Del
OK
locale.cpython-310.pyc
15.22 KB
Del
OK
locks.cpython-310.pyc
16.61 KB
Del
OK
log.cpython-310.pyc
8.07 KB
Del
OK
netutil.cpython-310.pyc
14.32 KB
Del
OK
options.cpython-310.pyc
19.63 KB
Del
OK
process.cpython-310.pyc
10.27 KB
Del
OK
queues.cpython-310.pyc
11.29 KB
Del
OK
routing.cpython-310.pyc
21.08 KB
Del
OK
simple_httpclient.cpython-310.pyc
16.08 KB
Del
OK
stack_context.cpython-310.pyc
10.65 KB
Del
OK
tcpclient.cpython-310.pyc
6.49 KB
Del
OK
tcpserver.cpython-310.pyc
10.06 KB
Del
OK
template.cpython-310.pyc
30.52 KB
Del
OK
testing.cpython-310.pyc
24.61 KB
Del
OK
util.cpython-310.pyc
13.72 KB
Del
OK
web.cpython-310.pyc
105.22 KB
Del
OK
websocket.cpython-310.pyc
39.08 KB
Del
OK
wsgi.cpython-310.pyc
11.5 KB
Del
OK
Edit: httpclient.cpython-310.pyc
o �xel � @ s� d Z ddlmZmZmZ ddlZddlZddlZddlm Z ddl mZmZ ddl mZmZ ddlmZ ddlmZ G d d � d e�ZG dd� de�ZG d d� de�ZG dd� de�ZG dd� de�ZG dd� de�Zdd� Zedkrwe� dS dS )a� Blocking and non-blocking HTTP client interfaces. This module defines a common interface shared by two implementations, ``simple_httpclient`` and ``curl_httpclient``. Applications may either instantiate their chosen implementation class directly or use the `AsyncHTTPClient` class from this module, which selects an implementation that can be overridden with the `AsyncHTTPClient.configure` method. The default implementation is ``simple_httpclient``, and this is expected to be suitable for most users' needs. However, some applications may wish to switch to ``curl_httpclient`` for reasons such as the following: * ``curl_httpclient`` has some features not found in ``simple_httpclient``, including support for HTTP proxies and the ability to use a specified network interface. * ``curl_httpclient`` is more likely to be compatible with sites that are not-quite-compliant with the HTTP spec, or sites that use little-exercised features of HTTP. * ``curl_httpclient`` is faster. * ``curl_httpclient`` was the default prior to Tornado 2.0. Note that if you are using ``curl_httpclient``, it is highly recommended that you use a recent version of ``libcurl`` and ``pycurl``. Currently the minimum supported version of libcurl is 7.22.0, and the minimum version of pycurl is 7.18.2. It is highly recommended that your ``libcurl`` installation is built with asynchronous DNS resolver (threaded or c-ares), otherwise you may encounter various problems with request timeouts (for more information, see http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTCONNECTTIMEOUTMS and comments in curl_httpclient.py). To select ``curl_httpclient``, call `AsyncHTTPClient.configure` at startup:: AsyncHTTPClient.configure("tornado.curl_httpclient.CurlAsyncHTTPClient") � )�absolute_import�division�print_functionN)�TracebackFuture)�utf8� native_str)�httputil� stack_context)�IOLoop)�Configurablec @ s2 e Zd ZdZddd�Zdd� Zdd� Zd d � ZdS )� HTTPClienta� A blocking HTTP client. This interface is provided for convenience and testing; most applications that are running an IOLoop will want to use `AsyncHTTPClient` instead. Typical usage looks like this:: http_client = httpclient.HTTPClient() try: response = http_client.fetch("http://www.google.com/") print(response.body) except httpclient.HTTPError as e: # HTTPError is raised for non-200 responses; the response # can be found in e.response. print("Error: " + str(e)) except Exception as e: # Other errors are possible, such as IOError. print("Error: " + str(e)) http_client.close() Nc K s6 t dd�| _|d u rt}|| jfi |��| _d| _d S )NF)Zmake_current)r �_io_loop�AsyncHTTPClient� _async_client�_closed)�selfZasync_client_class�kwargs� r �O/opt/saltstack/salt/lib/python3.10/site-packages/salt/ext/tornado/httpclient.py�__init__K s zHTTPClient.__init__c C s | � � d S �N)�close�r r r r �__del__R s zHTTPClient.__del__c C s( | j s| j�� | j�� d| _ dS dS )z2Closes the HTTPClient, freeing any resources used.TN)r r r r r r r r r U s �zHTTPClient.closec K s$ | j �tj| jj|fi |���}|S )a� Executes a request, returning an `HTTPResponse`. The request may be either a string URL or an `HTTPRequest` object. If it is a string, we construct an `HTTPRequest` using any additional kwargs: ``HTTPRequest(request, **kwargs)`` If an error occurs during the fetch, we raise an `HTTPError` unless the ``raise_error`` keyword argument is set to False. )r Zrun_sync� functools�partialr �fetch)r �requestr �responser r r r \ s ��zHTTPClient.fetchr )�__name__� __module__�__qualname__�__doc__r r r r r r r r r 7 s r c sz e Zd ZdZedd� �Zedd� �Zedd� �Zd� fd d� Zddd �Z dd� Z ddd�Zdd� Ze� fdd��Z � ZS )r a� An non-blocking HTTP client. Example usage:: def handle_response(response): if response.error: print("Error: %s" % response.error) else: print(response.body) http_client = AsyncHTTPClient() http_client.fetch("http://www.google.com/", handle_response) The constructor for this class is magic in several respects: It actually creates an instance of an implementation-specific subclass, and instances are reused as a kind of pseudo-singleton (one per `.IOLoop`). The keyword argument ``force_instance=True`` can be used to suppress this singleton behavior. Unless ``force_instance=True`` is used, no arguments other than ``io_loop`` should be passed to the `AsyncHTTPClient` constructor. The implementation subclass as well as arguments to its constructor can be set with the static method `configure()` All `AsyncHTTPClient` implementations support a ``defaults`` keyword argument, which can be used to set default values for `HTTPRequest` attributes. For example:: AsyncHTTPClient.configure( None, defaults=dict(user_agent="MyUserAgent")) # or with force_instance: client = AsyncHTTPClient(force_instance=True, defaults=dict(user_agent="MyUserAgent")) .. versionchanged:: 4.1 The ``io_loop`` argument is deprecated. c C s t S r )r )�clsr r r �configurable_base� s z!AsyncHTTPClient.configurable_basec C s ddl m} |S )Nr )�SimpleAsyncHTTPClient)Z"salt.ext.tornado.simple_httpclientr% )r# r% r r r �configurable_default� s z$AsyncHTTPClient.configurable_defaultc C s. d| j }t| |�st| |t�� � t| |�S )NZ_async_client_dict_)r �hasattr�setattr�weakref�WeakKeyDictionary�getattr)r# Z attr_namer r r �_async_clients� s zAsyncHTTPClient._async_clientsNFc sn |pt �� }|rd }n| �� }|d ur||v r|| S tt| �j| fd|i|��}||_|d ur5|||j<