HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //opt/osm/venv/lib64/python3.10/site-packages/urllib3/__pycache__/poolmanager.cpython-310.pyc
o

<i:]�@s�ddlmZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZmZddl
mZddlmZdd	lmZmZmZdd
lmZmZmZmZddlmZddlmZdd
lmZddl m!Z!ddl"m#Z#ddl$m%Z%m&Z&ej'rddl(Z(ddl)m*Z*gd�Z+e�,e-�Z.dZ/dZ0Gdd�dej1�Z2d)dd�Z3e�4e3e2�e�4e3e2�d�Z5eed�Z6Gdd �d e�Z7Gd!d"�d"e7�Z8d*d'd(�Z9dS)+�)�annotationsN)�
TracebackType)�urljoin�)�HTTPHeaderDict�RecentlyUsedContainer)�RequestMethods)�ProxyConfig)�HTTPConnectionPool�HTTPSConnectionPool�port_by_scheme)�LocationValueError�
MaxRetryError�ProxySchemeUnknown�URLSchemeUnknown)�BaseHTTPResponse)�_TYPE_SOCKET_OPTIONS)�connection_requires_http_tunnel)�Retry)�Timeout)�Url�	parse_url)�Self)�PoolManager�ProxyManager�proxy_from_url)�key_file�	cert_file�	cert_reqs�ca_certs�ca_cert_data�ssl_versionZssl_minimum_versionZssl_maximum_version�ca_cert_dir�ssl_context�key_password�server_hostnamei@c@s�eZdZUdZded<ded<ded<ded<d	ed
<ded<d
ed<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<ded<d ed!<d"ed#<d ed$<d%ed&<d'ed(<d ed)<d*ed+<ded,<ded-<ded.<d/S)0�PoolKeyz�
    All known keyword arguments that could be provided to the pool manager, its
    pools, or the underlying connections.

    All custom key schemes should include the fields in this key at a minimum.
    �str�
key_scheme�key_host�
int | None�key_portzTimeout | float | int | None�key_timeoutzRetry | bool | int | None�key_retrieszbool | None�	key_blockztuple[str, int] | None�key_source_address�
str | None�key_key_file�key_key_password�
key_cert_file�
key_cert_reqs�key_ca_certszstr | bytes | NoneZkey_ca_cert_datazint | str | None�key_ssl_versionzssl.TLSVersion | NoneZkey_ssl_minimum_versionZkey_ssl_maximum_version�key_ca_cert_dir�ssl.SSLContext | None�key_ssl_context�key_maxsizez!frozenset[tuple[str, str]] | None�key_headers�
Url | None�
key__proxy�key__proxy_headers�ProxyConfig | None�key__proxy_configz_TYPE_SOCKET_OPTIONS | None�key_socket_options�key__socks_optionszbool | str | None�key_assert_hostname�key_assert_fingerprint�key_server_hostname�
key_blocksizeN)�__name__�
__module__�__qualname__�__doc__�__annotations__�rLrL�A/opt/osm/venv/lib/python3.10/site-packages/urllib3/poolmanager.pyr&8s>
r&�	key_class�
type[PoolKey]�request_context�dict[str, typing.Any]�returncCs�|��}|d��|d<|d��|d<dD]}||vr,||dur,t||���||<q|�d�}|dur<t|�|d<t|���D]}|�|�|d|<qB|j	D]
}||vr[d||<qQ|�d�durgt
|d<|di|��S)	a�
    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
    �scheme�host)�headers�_proxy_headers�_socks_optionsN�socket_options�key_rFrL)�copy�lower�	frozenset�items�get�tuple�list�keys�pop�_fields�_DEFAULT_BLOCKSIZE)rNrP�context�key�socket_opts�fieldrLrLrM�_default_key_normalizer_s&�

�ri��http�httpscs�eZdZUdZdZded<dZded<		dHdI�fdd�
ZdJdd�ZdKdd�Z		dLdMd%d&�Z
dNd'd(�Z		)	dOdPd-d.�ZdQd0d1�Z
dRd4d5�Z	dLdSd7d8�ZdTd:d;�ZdUd?d@�Z	AdVdWdFdG�Z�ZS)XraV
    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:

    .. code-block:: python

        import urllib3

        http = urllib3.PoolManager(num_pools=2)

        resp1 = http.request("GET", "https://google.com/")
        resp2 = http.request("GET", "https://google.com/mail")
        resp3 = http.request("GET", "https://yahoo.com/")

        print(len(http.pools))
        # 2

    Nr<�proxyr?�proxy_config�
�	num_pools�intrU�typing.Mapping[str, str] | None�connection_pool_kw�
typing.AnyrR�Nonecszt��|�d|vr)|d}t|t�s)|du}tj|dd�}||_|��}||d<||_|t|�|_	t
|_
t��|_dS)N�retriesF��redirect)�super�__init__�
isinstancer�from_int�raise_on_redirectrZrsr�pools�pool_classes_by_scheme�key_fn_by_scheme)�selfrprUrsrvr}��	__class__rLrMrz�s
	
zPoolManager.__init__rcCs|S�NrL�r�rLrLrM�	__enter__�szPoolManager.__enter__�exc_type�type[BaseException] | None�exc_val�BaseException | None�exc_tb�TracebackType | None�typing.Literal[False]cCs|��dS)NF)�clear)r�r�r�r�rLrLrM�__exit__�szPoolManager.__exit__rSr'rT�portrP�dict[str, typing.Any] | Noner
cCsx|j|}|dur|j��}|�d�durt|d<dD]}|�|d�q|dkr3tD]}|�|d�q*|||fi|��S)a�
        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.
        N�	blocksize)rSrTr�rk)rrsrZr^rdrb�SSL_KEYWORDS)r�rSrTr�rP�pool_clsrf�kwrLrLrM�	_new_pool�s

zPoolManager._new_poolcCs|j��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�rLrLrMr�szPoolManager.clearrkr0r*�pool_kwargscCsT|std��|�|�}|pd|d<|st�|d��d�}||d<||d<|�|�S)a�
        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.
        zNo host specified.rkrS�Pr�rT)r
�_merge_pool_kwargsrr^r[�connection_from_context)r�rTr�rSr�rPrLrLrM�connection_from_host$s

z PoolManager.connection_from_hostrQcCsXd|vrt�dt�|�d�|d��}|j�|�}|s!t|��||�}|j||d�S)z�
        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.
        �strictzdThe 'strict' parameter is no longer needed on Python 3+. This will raise an error in urllib3 v2.1.0.rS�rP)	�warnings�warn�DeprecationWarningrbr[r�r^r�connection_from_pool_key)r�rPrS�pool_key_constructor�pool_keyrLrLrMr�As	�
z#PoolManager.connection_from_contextr�r&cCs�|jj�4|j�|�}|r|Wd�S|d}|d}|d}|j||||d�}||j|<Wd�|S1s;wY|S)a
        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.
        NrSrTr�r�)r~�lockr^r�)r�r�rP�poolrSrTr�rLrLrMr�Zs

�
��z$PoolManager.connection_from_pool_key�urlcCs t|�}|j|j|j|j|d�S)a�
        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.
        )r�rSr�)rr�rTr�rS)r�r�r��urLrLrM�connection_from_urlts
�zPoolManager.connection_from_url�overridec	CsR|j��}|r'|��D]\}}|dur"z||=Wqty!Yqw|||<q|S)a
        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)rsrZr]�KeyError)r�r��base_pool_kwargsrf�valuerLrLrMr��s


�
zPoolManager._merge_pool_kwargs�
parsed_urlr�boolcCs"|jdurdSt|j|j|j�S)z�
        Indicates if the proxy requires the complete destination URL in the
        request.  Normally this is only needed when not using an HTTP CONNECT
        tunnel.
        NF)rmrrnrS)r�r�rLrLrM�!_proxy_requires_url_absolute_form�s

�z-PoolManager._proxy_requires_url_absolute_formT�methodrxr�rcKs�t|�}|jdurtjdtdd�|j|j|j|jd�}d|d<d|d<d	|vr-|j|d	<|�	|�r=|j
||fi|��}n|j
||jfi|��}|oM|��}|sR|St
||�}|jd
krld}d|d<t|d	���|d	<|�d
|j�}	t|	t�stj|	|d�}	|	jr�|�|�s�|d	��}
|d	D]}|��|	jvr�|
�|d�q�|
|d	<z|	j||||d�}	Wnty�|	jr�|���|YSw|	|d
<||d<t� d||�|��|j
||fi|��S)aN
        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.
        Na	URLs without a scheme (ie 'https://') are deprecated and will raise an error in a future version of urllib3. To avoid this DeprecationWarning ensure all URLs start with 'https://' or 'http://'. Read more in this issue: https://github.com/urllib3/urllib3/issues/2920�)�category�
stacklevel)r�rSF�assert_same_hostrxrUi/�GET�bodyrvrw)�response�_poolzRedirecting %s -> %s)!rrSr�r�r�r�rTr�rUr��urlopen�request_uri�get_redirect_locationr�statusr�_prepare_for_method_changer^rvr{rr|�remove_headers_on_redirect�is_same_hostrZr[rb�	incrementrr}�
drain_conn�log�info)r�r�r�rxr�r��connr��redirect_locationrv�new_headers�headerrLrLrMr��s`
�	





���zPoolManager.urlopen)roN)rprqrUrrrsrtrRru)rRr)r�r�r�r�r�r�rRr�r�)
rSr'rTr'r�rqrPr�rRr
)rRru�NrkN�
rTr0r�r*rSr0r�r�rRr
)rPrQrRr
)r�r&rPrQrRr
)r�r'r�r�rRr
)r�r�rRrQ)r�rrRr��T�
r�r'r�r'rxr�r�rtrRr)rGrHrIrJrmrKrnrzr�r�r�r�r�r�r�r�r�r�r��
__classcell__rLrLr�rMr�s0
!�
!
�
&�

�

�rcsheZdZdZ							d/d0�fdd�
Z			d1d2�fd"d#�
Z	d3d4d&d'�Z	(d5d6�fd-d.�
Z�ZS)7ra>
    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.

    :param proxy_assert_hostname:
        The hostname of the certificate to verify against.

    :param proxy_assert_fingerprint:
        The fingerprint of the certificate to verify against.

    Example:

    .. code-block:: python

        import urllib3

        proxy = urllib3.ProxyManager("https://localhost:3128/")

        resp1 = proxy.request("GET", "https://google.com/")
        resp2 = proxy.request("GET", "https://httpbin.org/")

        print(len(proxy.pools))
        # 1

        resp3 = proxy.request("GET", "https://httpbin.org/")
        resp4 = proxy.request("GET", "https://twitter.com/")

        print(len(proxy.pools))
        # 3

    roNF�	proxy_urlr'rprqrUrr�
proxy_headers�proxy_ssl_contextr8�use_forwarding_for_httpsr��proxy_assert_hostname�"None | str | typing.Literal[False]�proxy_assert_fingerprintr0rsrtrRruc	
s�t|t�r|j�d|j�d|j��}
n|}
t|
�}|jdvr#t|j��|js3t�|jd�}|j	|d�}||_
|p9i|_||_t
||||�|_|j
|	d<|j|	d<|j|	d<t�j||fi|	��dS)	Nz://�:rjr�)r��_proxyrV�
_proxy_config)r{r
rSrTr�rrrr^�_replacermr�r�r	rnryrz)
r�r�rprUr�r�r�r�r�rsZ
str_proxy_urlrmr�r�rLrMrz3s,



�


zProxyManager.__init__rkrTr�r*rSr�r�r
cs<|dkrt�j||||d�St�j|jj|jj|jj|d�S)Nrl)r�)ryr�rmrTr�rS)r�rTr�rSr�r�rLrMr�\s��z!ProxyManager.connection_from_hostr��typing.Mapping[str, str]cCs0ddi}t|�j}|r||d<|r|�|�|S)z�
        Sets headers needed by proxies: specifically, the Accept and Host
        headers. Only sets headers not provided by the user.
        �Acceptz*/*�Host)r�netloc�update)r�r�rU�headers_r�rLrLrM�_set_proxy_headersls

zProxyManager._set_proxy_headersTr�rxr�rcsRt|�}t|j|j|j�s|�d|j�}|�||�|d<t�j	||fd|i|��S)z@Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute.rUrx)
rrrmrnrSr^rUr�ryr�)r�r�r�rxr�r�rUr�rLrMr�}s
zProxyManager.urlopen)roNNNFNN)r�r'rprqrUrrr�rrr�r8r�r�r�r�r�r0rsrtrRrur�r�r�)r�r'rUrrrRr�r�r�)	rGrHrIrJrzr�r�r�r�rLrLr�rMr�s$9�,���rr�r'r�rtcKstdd|i|��S)Nr�rL)r)r�r�rLrLrMr�sr)rNrOrPrQrRr&)r�r'r�rtrRr):�
__future__r�	functools�logging�typingr��typesr�urllib.parser�_collectionsrrZ_request_methodsr�
connectionr	�connectionpoolr
rr�
exceptionsr
rrrr�rZutil.connectionrZ
util.proxyrZ
util.retryrZutil.timeoutrZutil.urlrr�
TYPE_CHECKING�sslZtyping_extensionsr�__all__�	getLoggerrGr�r�rd�
NamedTupler&ri�partialr�rrrrrLrLrLrM�<module>sJ

'
<
�
\