HEX
Server: Apache
System: Linux br384.hostgator.com.br 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User: regi8665 (2159)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: //lib/python2.7/site-packages/urllib3/poolmanager.pyc
�
i�$ec@@s-ddlmZddlZddlZddlZddlmZddlmZm	Z	m
Z
ddlmZm
Z
mZmZmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZd
ddgZeje�Z dddddddddf	Z!dddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2fZ"ej#d3e"�Z$dd4fZ%ej#d5e%�Z&d6�Z'iej(e'e$�d76ej(e'e$�d86Z)ied76e	d86Z*d
efd9��YZ+de+fd:��YZ,d;�Z-dS(<i(tabsolute_importNi(tRecentlyUsedContainer(tHTTPConnectionPooltHTTPSConnectionPooltport_by_scheme(tLocationValueErrort
MaxRetryErrortProxySchemeUnknowntProxySchemeUnsupportedtURLSchemeUnknown(tsix(turljoin(tRequestMethods(tconnection_requires_http_tunnel(tRetry(t	parse_urltPoolManagertProxyManagertproxy_from_urltkey_filet	cert_filet	cert_reqstca_certstssl_versiontca_cert_dirtssl_contexttkey_passwordtserver_hostnamet
key_schemetkey_hosttkey_porttkey_timeouttkey_retriest
key_strictt	key_blocktkey_source_addresstkey_key_filetkey_key_passwordt
key_cert_filet
key_cert_reqstkey_ca_certstkey_ssl_versiontkey_ca_cert_dirtkey_ssl_contexttkey_maxsizetkey_headerst
key__proxytkey__proxy_headerstkey__proxy_configtkey_socket_optionstkey__socks_optionstkey_assert_hostnametkey_assert_fingerprinttkey_server_hostnametPoolKeytuse_forwarding_for_httpstProxyConfigcC@s|j�}|dj�|d<|dj�|d<xGdD]?}||kr;||d	k	r;t||j��||<q;q;W|jd�}|d	k	r�t|�|d<nx1t|j��D]}|j	|�|d|<q�Wx*|j
D]}||kr�d	||<q�q�W||�S(
s�
    Create a pool key out of a request context dictionary.

    According to RFC 3986, both the scheme and host are case-insensitive.
    Therefore, this function normalizes both before constructing the pool
    key for an HTTPS request. If you wish to change this behaviour, provide
    alternate callables to ``key_fn_by_scheme``.

    :param key_class:
        The class to use when constructing the key. This should be a namedtuple
        with the ``scheme`` and ``host`` keys at a minimum.
    :type  key_class: namedtuple
    :param request_context:
        A dictionary-like object that contain the context for a request.
    :type  request_context: dict

    :return: A namedtuple that can be used as a connection pool key.
    :rtype:  PoolKey
    tschemethosttheaderst_proxy_headerst_socks_optionstsocket_optionstkey_(sheaderss_proxy_headerss_socks_optionsN(tcopytlowertNonet	frozensettitemstgetttupletlisttkeystpopt_fields(t	key_classtrequest_contexttcontexttkeytsocket_optstfield((s7/usr/lib/python2.7/site-packages/urllib3/poolmanager.pyt_default_key_normalizerOs
!thttpthttpscB@s�eZdZdZdZddd�Zd�Zd�Zdd�Z	d�Z
dddd�Zd	�Zdd
�Z
dd�Zd�Zd
�Zd�Zed�ZRS(s$
    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

    i
cK@sDtj||�||_t|�|_t|_tj�|_dS(N(Rt__init__tconnection_pool_kwRtpoolstpool_classes_by_schemetkey_fn_by_schemeR@(tselft	num_poolsR;RU((s7/usr/lib/python2.7/site-packages/urllib3/poolmanager.pyRT�s
		cC@s|S(N((RY((s7/usr/lib/python2.7/site-packages/urllib3/poolmanager.pyt	__enter__�scC@s|j�tS(N(tcleartFalse(RYtexc_typetexc_valtexc_tb((s7/usr/lib/python2.7/site-packages/urllib3/poolmanager.pyt__exit__�s
cC@s�|j|}|dkr+|jj�}nxdD]}|j|d�q2W|dkr|x!tD]}|j|d�q_Wn||||�S(s�
        Create a new :class:`urllib3.connectionpool.ConnectionPool` based on host, port, scheme, and
        any additional pool keyword arguments.

        If ``request_context`` is provided, it is provided as keyword arguments
        to the pool class used. 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.
        R9R:tportRRN(sschemeshostsport(RWRBRUR@RItSSL_KEYWORDS(RYR9R:RbRLtpool_clsRNtkw((s7/usr/lib/python2.7/site-packages/urllib3/poolmanager.pyt	_new_pool�s



cC@s|jj�dS(s�
        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(RVR\(RY((s7/usr/lib/python2.7/site-packages/urllib3/poolmanager.pyR\�sRRcC@sz|std��n|j|�}|p-d|d<|sYtj|dj�d�}n||d<||d<|j|�S(s�
        Get a :class:`urllib3.connectionpool.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``. If ``pool_kwargs`` is
        provided, it is merged with the instance's ``connection_pool_kw``
        variable and used to create the new connection pool, if one is
        needed.
        sNo host specified.RRR9iPRbR:(Rt_merge_pool_kwargsRRERAtconnection_from_context(RYR:RbR9tpool_kwargsRL((s7/usr/lib/python2.7/site-packages/urllib3/poolmanager.pytconnection_from_host�s

cC@sV|dj�}|jj|�}|s7t|��n||�}|j|d|�S(s�
        Get a :class:`urllib3.connectionpool.ConnectionPool` based on the request context.

        ``request_context`` must at least contain the ``scheme`` key and its
        value must be a key in ``key_fn_by_scheme`` instance variable.
        R9RL(RARXRER	tconnection_from_pool_key(RYRLR9tpool_key_constructortpool_key((s7/usr/lib/python2.7/site-packages/urllib3/poolmanager.pyRh�sc
C@sy|jj�g|jj|�}|r)|S|d}|d}|d}|j|||d|�}||j|<WdQX|S(s
        Get a :class:`urllib3.connectionpool.ConnectionPool` based on the provided pool key.

        ``pool_key`` should be a namedtuple that only contains immutable
        objects. At a minimum it must have the ``scheme``, ``host``, and
        ``port`` fields.
        R9R:RbRLN(RVtlockRERf(RYRmRLtpoolR9R:Rb((s7/usr/lib/python2.7/site-packages/urllib3/poolmanager.pyRks



cC@s4t|�}|j|jd|jd|jd|�S(s�
        Similar to :func:`urllib3.connectionpool.connection_from_url`.

        If ``pool_kwargs`` is not provided and a new pool needs to be
        constructed, ``self.connection_pool_kw`` is used to initialize
        the :class:`urllib3.connectionpool.ConnectionPool`. If ``pool_kwargs``
        is provided, it is used instead. Note that if a new pool does not
        need to be created for the request, the provided ``pool_kwargs`` are
        not used.
        RbR9Ri(RRjR:RbR9(RYturlRitu((s7/usr/lib/python2.7/site-packages/urllib3/poolmanager.pytconnection_from_urlscC@sq|jj�}|rmxU|j�D]D\}}|dkr\y||=Wqftk
rXqfXq"|||<q"Wn|S(s
        Merge a dictionary of override values for self.connection_pool_kw.

        This does not modify self.connection_pool_kw and returns a new dict.
        Any keys in the override dictionary with a value of ``None`` are
        removed from the merged dictionary.
        N(RUR@RDRBtKeyError(RYtoverridetbase_pool_kwargsRNtvalue((s7/usr/lib/python2.7/site-packages/urllib3/poolmanager.pyRg/s
cC@s-|jdkrtSt|j|j|j�S(s�
        Indicates if the proxy requires the complete destination URL in the
        request.  Normally this is only needed when not using an HTTP CONNECT
        tunnel.
        N(tproxyRBR]R
tproxy_configR9(RYt
parsed_url((s7/usr/lib/python2.7/site-packages/urllib3/poolmanager.pyt!_proxy_requires_url_absolute_formCscC@s^|jdks|dkrdS|jjdkr5dStjrZ|jjrZtd��ndS(s�
        Validates that were not attempting to do TLS in TLS connections on
        Python2 or with unsupported SSL implementations.
        RSNsfContacting HTTPS destinations through HTTPS proxies 'via CONNECT tunnels' is not supported in Python 2(RwRBR9R
tPY2RxR7R(RYt
url_scheme((s7/usr/lib/python2.7/site-packages/urllib3/poolmanager.pyt$_validate_proxy_scheme_url_selectionPsc	K@s4t|�}|j|j�|j|jd|jd|j�}t|d<t|d<d|krv|jj�|d<n|j	|�r�|j
|||�}n|j
||j|�}|o�|j�}|s�|St
||�}|jdkr�d}n|jd�}	t|	t�s.tj|	d|�}	n|	jr�|j|�r�ttj|d��}
x=|
D]2}|j�|	jkrg|dj|d�qgqgWny"|	j||d	|d
|�}	Wn+tk
r�|	jr�|j��n|SX|	|d<||d<tj d||�|j�|j
|||�S(
sN
        Same as :meth:`urllib3.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.
        RbR9tassert_same_hosttredirectR;i/tGETtretriestresponset_poolsRedirecting %s -> %sN(!RR}R9RjR:RbR]R;R@Rzturlopentrequest_uritget_redirect_locationRtstatusREt
isinstanceRtfrom_inttremove_headers_on_redirecttis_same_hostRGR
titerkeysRARIRBt	incrementRtraise_on_redirectt
drain_conntlogtinfo(RYtmethodRpRReRqtconnR�tredirect_locationR�R;theader((s7/usr/lib/python2.7/site-packages/urllib3/poolmanager.pyR�asJ	$

	

"
	



N(t__name__t
__module__t__doc__RBRwRxRTR[RaRfR\RjRhRkRrRgRzR}tTrueR�(((s7/usr/lib/python2.7/site-packages/urllib3/poolmanager.pyR�s 
							
	cB@sPeZdZdddded�Zdddd�Zdd�Zed�Z	RS(s>
    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 containing 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.

    :param proxy_ssl_context:
        The proxy SSL context is used to establish the TLS connection to the
        proxy when using HTTPS proxies.

    :param use_forwarding_for_https:
        (Defaults to False) If set to True will forward requests to the HTTPS
        proxy to be made on behalf of the client instead of creating a TLS
        tunnel via the CONNECT method. **Enabling this flag means that request
        and response headers and content will be visible from the HTTPS proxy**
        whereas tunneling keeps request and response headers and content
        private.  IP address, target hostname, SNI, and port are always visible
        to an HTTPS proxy even when this flag is disabled.

    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

    i
c
K@st|t�r.d|j|j|jf}nt|�}|jd	kr[t|j��n|js�tj|jd�}	|j	d|	�}n||_
|p�i|_||_t
||�|_|j
|d<|j|d<|j|d<tt|�j|||�dS(
Ns
%s://%s:%iRRRSiPRbt_proxyR<t
_proxy_config(shttpshttps(R�RR9R:RbRRRREt_replaceRwt
proxy_headerstproxy_ssl_contextR8RxtsuperRRT(
RYt	proxy_urlRZR;R�R�R7RURwRb((s7/usr/lib/python2.7/site-packages/urllib3/poolmanager.pyRT�s&			


RRcC@sb|dkr.tt|�j|||d|�Stt|�j|jj|jj|jjd|�S(NRSRi(R�RRjRwR:RbR9(RYR:RbR9Ri((s7/usr/lib/python2.7/site-packages/urllib3/poolmanager.pyRj�s
cC@sIidd6}t|�j}|r/||d<n|rE|j|�n|S(s�
        Sets headers needed by proxies: specifically, the Accept and Host
        headers. Only sets headers not provided by the user.
        s*/*tAccepttHost(Rtnetloctupdate(RYRpR;theaders_R�((s7/usr/lib/python2.7/site-packages/urllib3/poolmanager.pyt_set_proxy_headers�s

cK@swt|�}t|j|j|j�sU|jd|j�}|j||�|d<ntt	|�j
||d||�S(s@Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute.R;R(RR
RwRxR9RER;R�R�RR�(RYR�RpRReRqR;((s7/usr/lib/python2.7/site-packages/urllib3/poolmanager.pyR�s
N(
R�R�R�RBR]RTRjR�R�R�(((s7/usr/lib/python2.7/site-packages/urllib3/poolmanager.pyR�s&
cK@std||�S(NR�(R(RpRe((s7/usr/lib/python2.7/site-packages/urllib3/poolmanager.pyRs(.t
__future__Rtcollectionst	functoolstloggingt_collectionsRtconnectionpoolRRRt
exceptionsRRRRR	tpackagesR
tpackages.six.moves.urllib.parseRtrequestRt
util.proxyR
t
util.retryRtutil.urlRt__all__t	getLoggerR�R�Rct_key_fieldst
namedtupleR6t_proxy_config_fieldsR8RQtpartialRXRWRRR(((s7/usr/lib/python2.7/site-packages/urllib3/poolmanager.pyt<module>sz(			5�s