
    q"hN                        S SK Jr  S SKrS SKrS SKrSSKJrJr  SSKJ	r	J
r
Jr  SSKJrJrJrJrJr  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr  / SQr\R>                  " \ 5      r!Sr"Sr#\RH                  " S\#5      r%Sr&\RH                  " S\&5      r'S r(\RR                  " \(\%5      \RR                  " \(\%5      S.r*\	\
S.r+ " S S\5      r, " S S\,5      r-S r.g)    )absolute_importN   )HTTPHeaderDictRecentlyUsedContainer)HTTPConnectionPoolHTTPSConnectionPoolport_by_scheme)LocationValueErrorMaxRetryErrorProxySchemeUnknownProxySchemeUnsupportedURLSchemeUnknown)six)urljoin)RequestMethods)connection_requires_http_tunnel)Retry)	parse_url)PoolManagerProxyManagerproxy_from_url)	key_file	cert_file	cert_reqsca_certsssl_versionca_cert_dirssl_contextkey_passwordserver_hostname)
key_schemekey_hostkey_portkey_timeoutkey_retries
key_strict	key_blockkey_source_addresskey_key_filekey_key_passwordkey_cert_filekey_cert_reqskey_ca_certskey_ssl_versionkey_ca_cert_dirkey_ssl_contextkey_maxsizekey_headers
key__proxykey__proxy_headerskey__proxy_configkey_socket_optionskey__socks_optionskey_assert_hostnamekey_assert_fingerprintkey_server_hostnamePoolKey)r   use_forwarding_for_httpsProxyConfigc                    UR                  5       nUS   R                  5       US'   US   R                  5       US'   S H.  nX2;   d  M
  X#   c  M  [        X#   R                  5       5      X#'   M0     UR	                  S5      nUb  [        U5      US'   [        UR                  5       5       H  nUR                  U5      USU-   '   M     U R                   H  nXR;  d  M
  SX%'   M     U " S0 UD6$ )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_ )
copylower	frozensetitemsgettuplelistkeyspop_fields)	key_classrequest_contextcontextkeysocket_optsfields         Q/var/www/html/env/lib/python3.13/site-packages/pip/_vendor/urllib3/poolmanager.py_default_key_normalizerrX   O   s    * ""$G)//1GHfo++-GFO ?>gl6$W\%7%7%9:GL ? ++./K$)+$6 ! GLLN# 'C 0 $ ""!GN # w    httphttpsc                       \ rS rSrSrSrSrSS jrS rS r	SS jr
S rSS	 jrS
 rSS jrSS jrS rS rS rSS jrSrg)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

Nc                     [         R                  " X5        X0l        [        U5      U l        [
        U l        [        R                  5       U l        g N)r   __init__connection_pool_kwr   poolspool_classes_by_schemekey_fn_by_schemerG   )self	num_poolsrA   rb   s       rW   ra   PoolManager.__init__   s=    ."4*95
 '=# 0 5 5 7rY   c                     U $ r`   rF   rf   s    rW   	__enter__PoolManager.__enter__   s    rY   c                 $    U R                  5         g)NF)clear)rf   exc_typeexc_valexc_tbs       rW   __exit__PoolManager.__exit__   s    

rY   c                     U R                   U   nUc  U R                  R                  5       nS H  nUR                  US5        M     US:X  a  [         H  nUR                  US5        M     U" X#40 UD6$ )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)r?   r@   portr[   )rd   rb   rG   rO   SSL_KEYWORDS)rf   r?   r@   ru   rR   pool_clsrT   kws           rW   	_new_poolPoolManager._new_pool   s     ..v6""55::<O .CT* . V"##B- # 6o66rY   c                 8    U R                   R                  5         g)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)rc   rn   rj   s    rW   rn   PoolManager.clear   s     	

rY   c                     U(       d  [        S5      eU R                  U5      nU=(       d    SUS'   U(       d(  [        R                  " US   R	                  5       S5      nX%S'   XS'   U R                  U5      $ )al  
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.
zNo host specified.r[   r?   P   ru   r@   )r
   _merge_pool_kwargsr	   rK   rH   connection_from_context)rf   r@   ru   r?   pool_kwargsrR   s         rW   connection_from_host PoolManager.connection_from_host   sv     $%9::11+>$*$4f!!%%oh&?&E&E&GLD"&"&++O<<rY   c                     US   R                  5       nU R                  R                  U5      nU(       d  [        U5      eU" U5      nU R	                  XAS9$ )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.
r?   rR   )rH   re   rK   r   connection_from_pool_key)rf   rR   r?   pool_key_constructorpool_keys        rW   r   #PoolManager.connection_from_context   sZ     !*002#4488@#"6**'8,,X,WWrY   c                    U R                   R                     U R                   R                  U5      nU(       a  UsSSS5        $ US   nUS   nUS   nU R                  XEXbS9nX0R                   U'   SSS5        U$ ! , (       d  f       W$ = f)z
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.
Nr?   r@   ru   r   )rc   lockrK   ry   )rf   r   rR   poolr?   r@   ru   s          rW   r   $PoolManager.connection_from_pool_key  s     ZZ__ ::>>(+D _ %X.F"6*D"6*D>>&>VD#'JJx    _ s   $A<-A<<
Bc                 x    [        U5      nU R                  UR                  UR                  UR                  US9$ )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.
)ru   r?   r   )r   r   r@   ru   r?   )rf   urlr   us       rW   connection_from_urlPoolManager.connection_from_url  s:     cN((FFk ) 
 	
rY   c                     U R                   R                  5       nU(       a%  UR                  5        H  u  p4Uc   X#	 M  XBU'   M     U$ ! [         a     M$  f = f)z
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.
)rb   rG   rJ   KeyError)rf   overridebase_pool_kwargsrT   values        rW   r   PoolManager._merge_pool_kwargs/  se      22779&nn.
=,1 -2S) /  	 $ s   A		
AAc                 ~    U R                   c  g[        U R                   U R                  UR                  5      (       + $ )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.
F)proxyr   proxy_configr?   )rf   
parsed_urls     rW   !_proxy_requires_url_absolute_form-PoolManager._proxy_requires_url_absolute_formC  s:     ::2JJ)):+<+<
 
 	
rY   c                     U R                   b  US:w  a  gU R                   R                  S:w  a  g[        R                  (       a'  U R                  R
                  (       d  [        S5      egg)zu
Validates that were not attempting to do TLS in TLS connections on
Python2 or with unsupported SSL implementations.
Nr\   zfContacting HTTPS destinations through HTTPS proxies 'via CONNECT tunnels' is not supported in Python 2)r   r?   r   PY2r   r<   r   )rf   
url_schemes     rW   $_validate_proxy_scheme_url_selection0PoolManager._validate_proxy_scheme_url_selectionP  s]    
 ::w!6::'774,,EE(E  F7rY   c                    [        U5      nU R                  UR                  5        U R                  UR                  UR
                  UR                  S9nSUS'   SUS'   SU;  a  U R                  R                  5       US'   U R                  U5      (       a  UR                  " X40 UD6nOUR                  " XR                  40 UD6nU=(       a    UR                  5       nU(       d  U$ [        X(5      nUR                  S:X  a&  SnSUS	'   [        US   5      R                  5       US'   UR!                  S
5      n	[#        U	[$        5      (       d  [$        R&                  " XS9n	U	R(                  (       av  UR+                  U5      (       d`  [-        [.        R0                  " US   5      5      n
U
 H8  nUR3                  5       U	R(                  ;   d  M#  US   R5                  US5        M:      U	R7                  XXvS9n	XS
'   X4S'   [>        RA                  SX(5        UR=                  5         U R                  " X40 UD6$ ! [8         a'    U	R:                  (       a  UR=                  5         e Us $ f = f)a  
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.
)ru   r?   Fassert_same_hostredirectrA   i/  GETNbodyretries)r   )response_poolzRedirecting %s -> %s)!r   r   r?   r   r@   ru   rA   rG   r   urlopenrequest_uriget_redirect_locationr   statusr   _prepare_for_method_changerK   
isinstancer   from_intremove_headers_on_redirectis_same_hostrM   r   iterkeysrH   rO   	incrementr   raise_on_redirect
drain_connloginfo)rf   methodr   r   rx   r   connr   redirect_locationr   rA   headers               rW   r   PoolManager.urlopena  s(    cN11!((;((affQXX(N!&:B LL--/ByM11!44||F626H||FMM@R@H$I)G)G)I O $C;??c!FBvJ*2i=9TTVByM&&#'5))nnW@G
 --d6G6G7
 7
 3<<967G!<<>W%G%GGyM%%fd3 "	''h'SG  9!:'@||F<<<  	((##%O		s   /I   .I10I1)rb   re   rd   rc   )
   Nr`   Nr[   NT)__name__
__module____qualname____firstlineno____doc__r   r   ra   rk   rr   ry   rn   r   r   r   r   r   r   r   r   __static_attributes__rF   rY   rW   r   r      sV    6 EL8
76=.X0
  (
"D=rY   r   c                   d   ^  \ rS rSrSr     SU 4S jjrS	U 4S jjrS
S jrSU 4S jjrSr	U =r
$ )r   i  a  
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

c                 :  > [        U[        5      (       a&  SUR                  UR                  UR                  4-  n[        U5      nUR                  S;  a  [        UR                  5      eUR                  (       d0  [        R                  " UR                  S5      n	UR                  U	S9nXl
        U=(       d    0 U l        XPl        [        XV5      U l        U R                  US'   U R                  US'   U R                  US'   [        [         U ]F  " X#40 UD6  g )Nz
%s://%s:%irZ   r~   )ru   _proxyrB   _proxy_config)r   r   r?   r@   ru   r   r   r	   rK   _replacer   proxy_headersproxy_ssl_contextr=   r   superr   ra   )rf   	proxy_urlrg   rA   r   r   r<   rb   r   ru   	__class__s             rW   ra   ProxyManager.__init__  s     i!344$  ( I
 )$<<00$U\\22zz!%%ellB7DNNN-E
*0b!2'(9T'+zz8$/3/A/A+,.2.?.??+lD*9TASTrY   c                    > US:X  a  [         [        U ]  XX4S9$ [         [        U ]  U R                  R                  U R                  R
                  U R                  R                  US9$ )Nr\   )r   )r   r   r   r   r@   ru   r?   )rf   r@   ru   r?   r   r   s        rW   r   !ProxyManager.connection_from_host  sh    WtAF B   \4=JJOOTZZ__djj.?.?[ > 
 	
rY   c                 ~    SS0n[        U5      R                  nU(       a  XCS'   U(       a  UR                  U5        U$ )zx
Sets headers needed by proxies: specifically, the Accept and Host
headers. Only sets headers not provided by the user.
Acceptz*/*Host)r   netlocupdate)rf   r   rA   headers_r   s        rW   _set_proxy_headersProxyManager._set_proxy_headers  s<    
 e$3&&%VOOG$rY   c                   > [        U5      n[        U R                  U R                  UR                  5      (       d0  UR                  SU R                  5      nU R                  X&5      US'   [        [        U ]*  " X4SU0UD6$ )z@Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute.rA   r   )r   r   r   r   r?   rK   rA   r   r   r   r   )rf   r   r   r   rx   r   rA   r   s          rW   r   ProxyManager.urlopen  sp    cN.tzz4;L;LahhWW ffY5G 33CAByM\40VxVSUVVrY   )r   r   r   r   )r   NNNFr   r`   r   )r   r   r   r   r   ra   r   r   r   r   __classcell__)r   s   @rW   r   r     s7    %T !&#UJ

W 
WrY   r   c                     [        SSU 0UD6$ )Nr   rF   )r   )r   rx   s     rW   r   r     s    ,#,,,rY   )/
__future__r   collections	functoolslogging_collectionsr   r   connectionpoolr   r   r	   
exceptionsr
   r   r   r   r   packagesr   packages.six.moves.urllib.parser   requestr   
util.proxyr   
util.retryr   util.urlr   __all__	getLoggerr   r   rv   _key_fields
namedtupler;   _proxy_config_fieldsr=   rX   partialre   rd   r   r   r   rF   rY   rW   <module>r      s    &    ? S S   4 # 7  
; !
> 
 
 K
8B $$]4HI. l 5w?6@ 
 #5?RS Y=. Y=xpW; pWf-rY   