MOON
Server: Apache
System: Linux server30c.hostingraja.org 3.10.0-962.3.2.lve1.5.63.el7.x86_64 #1 SMP Fri Oct 8 12:03:35 UTC 2021 x86_64
User: jibhires (1887)
PHP: 8.1.30
Disabled: show_source, system, shell_exec, passthru, exec, popen, proc_open, allow_url_fopen, symlink, escapeshellcmd, pcntl_exec
Upload Files
File: //opt/alt/python35/lib/python3.5/site-packages/urllib3/__pycache__/poolmanager.cpython-35.opt-1.pyc


��V�%�@sIddlmZddlZyddlmZWn"ek
rTddlmZYnXddlmZddl	m
Z
mZddl	mZddl
mZmZmZdd	lmZdd
lmZddlmZdd
dgZeje�ZdZde
deiZGdd�de�ZGdd
�d
e�Zdd�ZdS)�)�absolute_importN)�urljoin�)�RecentlyUsedContainer)�HTTPConnectionPool�HTTPSConnectionPool)�port_by_scheme)�LocationValueError�
MaxRetryError�ProxySchemeUnknown)�RequestMethods)�	parse_url)�Retry�PoolManager�ProxyManager�proxy_from_url�key_file�	cert_file�	cert_reqs�ca_certs�ssl_version�ca_cert_dir�http�httpsc@s�eZdZdZdZdddd�Zdd�Zdd	�Zd
d�Zdd
�Z	dddd�Z
dd�Zddd�ZdS)ra$
    Allows for arbitrary requests while transparently keeping track of
    necessary connection pools for you.

    :param num_pools:
        Number of connection pools to cache before discarding the least
        recently used pool.

    :param headers:
        Headers to include with all requests, unless other headers are given
        explicitly.

    :param \**connection_pool_kw:
        Additional parameters are used to create fresh
        :class:`urllib3.connectionpool.ConnectionPool` instances.

    Example::

        >>> manager = PoolManager(num_pools=2)
        >>> r = manager.request('GET', 'http://google.com/')
        >>> r = manager.request('GET', 'http://google.com/mail')
        >>> r = manager.request('GET', 'http://yahoo.com/')
        >>> len(manager.pools)
        2

    N�
cKsAtj||�||_t|ddd��|_t|_dS)NZdispose_funccSs
|j�S)N)�close)�p�r�/poolmanager.py�<lambda>Bsz&PoolManager.__init__.<locals>.<lambda>)r�__init__�connection_pool_kwr�pools�pool_classes_by_scheme)�self�	num_pools�headersr!rrrr >s
		zPoolManager.__init__cCs|S)Nr)r$rrr�	__enter__GszPoolManager.__enter__cCs|j�dS)NF)�clear)r$�exc_type�exc_val�exc_tbrrr�__exit__Js
zPoolManager.__exit__cCsb|j|}|j}|dkrR|jj�}xtD]}|j|d�q8W||||�S)a
        Create a new :class:`ConnectionPool` based on host, port and scheme.

        This method is used to actually create the connection pools handed out
        by :meth:`connection_from_url` and companion methods. It is intended
        to be overridden for customization.
        rN)r#r!�copy�SSL_KEYWORDS�pop)r$�scheme�host�portZpool_cls�kwargs�kwrrr�	_new_poolOs
	
zPoolManager._new_poolcCs|jj�dS)z�
        Empty our store of pools and direct them all to close.

        This will not affect in-flight connections, but they will not be
        re-used after completion.
        N)r"r()r$rrrr(`szPoolManager.clearrcCs�|std��|pd}|p3tj|d�}|||f}|jj�C|jj|�}|rn|S|j|||�}||j|<WdQRX|S)z�
        Get a :class:`ConnectionPool` based on the host, port, and scheme.

        If ``port`` isn't given, it will be derived from the ``scheme`` using
        ``urllib3.connectionpool.port_by_scheme``.
        zNo host specified.r�PN)r	r�getr"�lockr5)r$r1r2r0Zpool_key�poolrrr�connection_from_hostis
z PoolManager.connection_from_hostcCs.t|�}|j|jd|jd|j�S)a*
        Similar to :func:`urllib3.connectionpool.connection_from_url` but
        doesn't pass any additional parameters to the
        :class:`urllib3.connectionpool.ConnectionPool` constructor.

        Additional parameters are taken from the :class:`.PoolManager`
        constructor.
        r2r0)r
r:r1r2r0)r$�url�urrr�connection_from_url�s	zPoolManager.connection_from_urlTc

Ks�t|�}|j|jd|jd|j�}d|d<d|d<d|kr]|j|d<|jdk	r�|jdkr�|j|||�}n|j||j|�}|o�|j	�}|s�|St
||�}|jd	kr�d
}|jd�}	t
|	t�stj|	d|�}	y"|	j||d|d
|�}	Wn"tk
rd|	jr\�|SYnX|	|d<||d<tjd||�|j|||�S)a]
        Same as :meth:`urllib3.connectionpool.HTTPConnectionPool.urlopen`
        with custom cross-host redirect logic and only sends the request-uri
        portion of the ``url``.

        The given ``url`` parameter must be absolute, such that an appropriate
        :class:`urllib3.connectionpool.ConnectionPool` can be chosen for it.
        r2r0FZassert_same_host�redirectr&Nri/�GET�retries�responseZ_poolzRedirecting %s -> %s)r
r:r1r2r0r&�proxy�urlopenZrequest_uriZget_redirect_locationr�statusr7�
isinstancerZfrom_intZ	incrementr
Zraise_on_redirect�log�info)
r$�methodr;r>r4r<�connrAZredirect_locationr@rrrrC�s8	$


"
		

zPoolManager.urlopen)
�__name__�
__module__�__qualname__�__doc__rBr r'r,r5r(r:r=rCrrrrr s		csmeZdZdZddd�fdd�Zdd�fdd�Zdd	d
�Zd�fdd
�Z�S)raw
    Behaves just like :class:`PoolManager`, but sends all requests through
    the defined proxy, using the CONNECT method for HTTPS URLs.

    :param proxy_url:
        The URL of the proxy to be used.

    :param proxy_headers:
        A dictionary contaning headers that will be sent to the proxy. In case
        of HTTP they are being sent with each request, while in the
        HTTPS/CONNECT case they are sent only once. Could be used for proxy
        authentication.

    Example:
        >>> proxy = urllib3.ProxyManager('http://localhost:3128/')
        >>> r1 = proxy.request('GET', 'http://google.com/')
        >>> r2 = proxy.request('GET', 'http://httpbin.org/')
        >>> len(proxy.pools)
        1
        >>> r3 = proxy.request('GET', 'https://httpbin.org/')
        >>> r4 = proxy.request('GET', 'https://twitter.com/')
        >>> len(proxy.pools)
        3

    rNcs�t|t�r+d|j|j|jf}t|�}|jsgtj|jd�}|jd|�}|jdkr�t	|j��||_
|p�i|_|j
|d<|j|d<tt
|�j|||�dS)	Nz
%s://%s:%ir6r2rr�_proxyZ_proxy_headers)zhttpr)rErr0r1r2r
rr7�_replacerrB�
proxy_headers�superrr )r$�	proxy_urlr%r&rPr!rBr2)�	__class__rrr �s
		

zProxyManager.__init__rcsV|dkr(tt|�j|||�Stt|�j|jj|jj|jj�S)Nr)rQrr:rBr1r2r0)r$r1r2r0)rSrrr:�s

z!ProxyManager.connection_from_hostcCsBddi}t|�j}|r+||d<|r>|j|�|S)z�
        Sets headers needed by proxies: specifically, the Accept and Host
        headers. Only sets headers not provided by the user.
        ZAcceptz*/*ZHost)r
�netloc�update)r$r;r&Zheaders_rTrrr�_set_proxy_headers�s

zProxyManager._set_proxy_headersTcsht|�}|jdkrF|jd|j�}|j||�|d<tt|�j||d||�S)z@Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute.rr&r>)r
r0r7r&rVrQrrC)r$rHr;r>r4r<r&)rSrrrC
s
zProxyManager.urlopen)rJrKrLrMr r:rVrCrr)rSrr�scKstd||�S)NrR)r)r;r4rrrrs)rrrrrr) Z
__future__r�loggingZurllib.parser�ImportError�urlparse�_collectionsrZconnectionpoolrrr�
exceptionsr	r
rZrequestrZutil.urlr
Z
util.retryr�__all__�	getLoggerrJrFr.r#rrrrrrr�<module>s*
�W