<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
U
    .eB                     @   s  d dl mZ d dlZd dlZd dlZddlmZ ddlmZm	Z	 ddlm
Z
 ddlmZmZmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ dddgZeeZdZdZedeZ dd Z!e"e!e e"e!e dZ#ee	dZ$G dd deZ%G dd de%Z&dd Z'dS )    )absolute_importN   )RecentlyUsedContainer)HTTPConnectionPoolHTTPSConnectionPool)port_by_scheme)LocationValueErrorMaxRetryErrorProxySchemeUnknown)six)urljoin)RequestMethods)	parse_url)RetryPoolManagerProxyManagerproxy_from_url)Zkey_fileZ	cert_fileZ	cert_reqsZca_certsZssl_versionZca_cert_dirZssl_contextZkey_password)Z
key_schemeZkey_hostZkey_portZkey_timeoutZkey_retriesZ
key_strictZ	key_blockZkey_source_addressZkey_key_fileZkey_key_passwordZkey_cert_fileZkey_cert_reqsZkey_ca_certsZkey_ssl_versionZkey_ca_cert_dirZkey_ssl_contextZkey_maxsizeZkey_headersZ
key__proxyZkey__proxy_headersZkey_socket_optionsZkey__socks_optionsZkey_assert_hostnameZkey_assert_fingerprintZkey_server_hostnamePoolKeyc                 C   s   |  }|d  |d< |d  |d< dD ],}||kr,|| dk	r,t||  ||< q,|d}|dk	rxt||d< t| D ]}|||d| < q| j	D ]}||krd||< q| f |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_headersZ_socks_optionsNZsocket_optionsZkey_)
copylower	frozensetitemsgettuplelistkeyspop_fields)Z	key_classrequest_contextcontextkeyZsocket_optsZfield r%   C/usr/lib/python3.8/site-packages/pip/_vendor/urllib3/poolmanager.py_default_key_normalizerD   s    


r'   httphttpsc                   @   sx   e Zd ZdZdZdddZdd Zdd	 Zdd
dZdd Z	dddZ
dd ZdddZd ddZdd Zd!ddZdS )"r   a$  
    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
   c                 K   s8   t | | || _t|dd d| _t| _t | _d S )Nc                 S   s   |   S N)close)pr%   r%   r&   <lambda>       z&PoolManager.__init__.<locals>.<lambda>)Zdispose_func)r   __init__connection_pool_kwr   poolspool_classes_by_schemekey_fn_by_schemer   )self	num_poolsr   r2   r%   r%   r&   r1      s
    zPoolManager.__init__c                 C   s   | S r,   r%   r6   r%   r%   r&   	__enter__   s    zPoolManager.__enter__c                 C   s   |    dS )NF)clear)r6   exc_typeZexc_valZexc_tbr%   r%   r&   __exit__   s    zPoolManager.__exit__c                 C   s^   | j | }|dkr| j }dD ]}||d q |dkrPtD ]}||d q>|||f|S )a  
        Create a new :class:`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)r   r   portr)   )r4   r2   r   r    SSL_KEYWORDS)r6   r   r   r=   r"   Zpool_clsr$   kwr%   r%   r&   	_new_pool   s    


zPoolManager._new_poolc                 C   s   | j   dS )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)r3   r:   r8   r%   r%   r&   r:      s    zPoolManager.clearr)   c                 C   sT   |st d| |}|pd|d< |s:t|d  d}||d< ||d< | |S )a  
        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``. 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.
        zNo host specified.r)   r   P   r=   r   )r   _merge_pool_kwargsr   r   r   connection_from_context)r6   r   r=   r   pool_kwargsr"   r%   r%   r&   connection_from_host   s    
z PoolManager.connection_from_hostc                 C   s,   |d   }| j| }||}| j||dS )z
        Get a :class:`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.
        r   r"   )r   r5   connection_from_pool_key)r6   r"   r   Zpool_key_constructorpool_keyr%   r%   r&   rC      s    
z#PoolManager.connection_from_contextc              
   C   sl   | j jZ | j |}|r*|W  5 Q R  S |d }|d }|d }| j||||d}|| j |< W 5 Q R X |S )z
        Get a :class:`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.
        r   r   r=   rF   )r3   lockr   r@   )r6   rH   r"   Zpoolr   r   r=   r%   r%   r&   rG      s    
z$PoolManager.connection_from_pool_keyc                 C   s    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=   r   rD   )r   rE   r   r=   r   )r6   urlrD   ur%   r%   r&   connection_from_url  s       zPoolManager.connection_from_urlc              	   C   sV   | j  }|rR| D ]:\}}|dkrHz
||= W qP tk
rD   Y qPX q|||< 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)r2   r   r   KeyError)r6   overrideZbase_pool_kwargsr$   valuer%   r%   r&   rB   !  s    


zPoolManager._merge_pool_kwargsTc                 K   s  t |}| j|j|j|jd}d|d< d|d< d|krD| j |d< | jdk	rj|jdkrj|j||f|}n|j||j	f|}|o|
 }|s|S t||}|jdkrd	}|d
}	t|	tstj|	|d}	|	jr||stt|d }
|
D ]"}| |	jkr|d |d qz|	j||||d}	W n$ tk
rR   |	jrJ | Y S X |	|d
< ||d< td|| | j||f|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.
        )r=   r   FZassert_same_hostredirectr   Nr)   i/  ZGETretries)rP   )responseZ_poolzRedirecting %s -> %s)r   rE   r   r=   r   r   r   proxyurlopenZrequest_uriZget_redirect_locationr   Zstatusr   
isinstancer   Zfrom_intZremove_headers_on_redirectZis_same_hostr   r   Ziterkeysr   r    Z	incrementr	   Zraise_on_redirectloginfo)r6   methodrJ   rP   r?   rK   ZconnrR   Zredirect_locationrQ   r   headerr%   r%   r&   rT   5  sF    	




zPoolManager.urlopen)r+   N)N)Nr)   N)N)N)T)__name__
__module____qualname____doc__rS   r1   r9   r<   r@   r:   rE   rC   rG   rL   rB   rT   r%   r%   r%   r&   r      s   


	


c                       sH   e Zd ZdZd fdd	Zd fdd	Zdd	d
Zd fdd	Z  ZS )r   ax  
    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.

    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

    r+   Nc                    s   t |trd|j|j|jf }t|}|jsFt|jd}|j|d}|jdkrZt	|j|| _
|pfi | _| j
|d< | j|d< tt| j||f| d S )Nz
%s://%s:%irA   )r=   r(   _proxyr   )rU   r   r   r   r=   r   r   r   _replacer
   rS   proxy_headerssuperr   r1   )r6   	proxy_urlr7   r   r`   r2   rS   r=   	__class__r%   r&   r1     s"    	





zProxyManager.__init__r)   c                    sD   |dkr t t| j||||dS t t| j| jj| jj| jj|dS )Nr*   )rD   )ra   r   rE   rS   r   r=   r   )r6   r   r=   r   rD   rc   r%   r&   rE     s    
   
   z!ProxyManager.connection_from_hostc                 C   s0   ddi}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.
        ZAcceptz*/*ZHost)r   netlocupdate)r6   rJ   r   Zheaders_re   r%   r%   r&   _set_proxy_headers  s    

zProxyManager._set_proxy_headersTc                    sN   t |}|jdkr0|d| j}| |||d< tt| j||fd|i|S )z@Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute.r)   r   rP   )r   r   r   r   rg   ra   r   rT   )r6   rX   rJ   rP   r?   rK   r   rc   r%   r&   rT     s
    
zProxyManager.urlopen)r+   NN)Nr)   N)N)T)	rZ   r[   r\   r]   r1   rE   rg   rT   __classcell__r%   r%   rc   r&   r   t  s      

c                 K   s   t f d| i|S )Nrb   )r   )rJ   r?   r%   r%   r&   r     s    )(Z
__future__r   collections	functoolsZlogging_collectionsr   Zconnectionpoolr   r   r   
exceptionsr   r	   r
   Zpackagesr   Zpackages.six.moves.urllib.parser   Zrequestr   Zutil.urlr   Z
util.retryr   __all__Z	getLoggerrZ   rV   r>   Z_key_fields
namedtupler   r'   partialr5   r4   r   r   r   r%   r%   r%   r&   <module>   s4   

6


 ta