
    hY                        S SK Jr  S SKrS SKrS SKrS SKrS SKJr  S SKJ	r	  SSK
JrJr  SSKJr  SSKJr  SS	KJrJrJr  SS
K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%J&r&  \RN                  (       a
  S SK(r(S SK)J*r*  / SQr+\RX                  " \-5      r.Sr/Sr0 " S S\Rb                  5      r2      SS jr3\Rh                  " \3\25      \Rh                  " \3\25      S.r5\\S.r6 " S S\5      r7 " S S\75      r8SS jr9g)     )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_versionssl_minimum_versionssl_maximum_versionca_cert_dirssl_contextkey_passwordserver_hostnamei @  c                  <   \ rS rSr% SrS\S'   S\S'   S\S'   S\S	'   S
\S'   S\S'   S\S'   S\S'   S\S'   S\S'   S\S'   S\S'   S\S'   S\S'   S\S'   S\S'   S\S'   S\S'   S\S '   S!\S"'   S#\S$'   S!\S%'   S&\S''   S(\S)'   S!\S*'   S+\S,'   S\S-'   S\S.'   S\S/'   S0rg1)2PoolKey8   z
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_portzTimeout | float | int | Nonekey_timeoutzRetry | bool | int | Nonekey_retrieszbool | None	key_blockztuple[str, int] | Nonekey_source_address
str | Nonekey_key_filekey_key_passwordkey_cert_filekey_cert_reqskey_ca_certszstr | bytes | Nonekey_ca_cert_datazint | str | Nonekey_ssl_versionzssl.TLSVersion | Nonekey_ssl_minimum_versionkey_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_optionszbool | str | Nonekey_assert_hostnamekey_assert_fingerprintkey_server_hostnamekey_blocksize N)__name__
__module____qualname____firstlineno____doc____annotations____static_attributes__rO       E/var/www/html/env/lib/python3.13/site-packages/urllib3/poolmanager.pyr*   r*   8   s     OM--**..  ((%%2222**2299))3399**&&##rW   r*   c                   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R	                  S5      c	  [        US'   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_rN   rO   )copylower	frozensetitemsgettuplelistkeyspop_fields_DEFAULT_BLOCKSIZE)	key_classrequest_contextcontextkeysocket_optsfields         rX   _default_key_normalizerrr   _   s   . ""$G)//1GHfo++-GFO ?>gl6$W\%7%7%9:GL ? ++./K$)+$6 ! GLLN# 'C 0 $ ""!GN #
 {{?#+#5 wrW   httphttpsc                  Z  ^  \ rS rSr% SrSrS\S'   SrS\S'     S       SU 4S jjjrSS	 jr	        SS
 jr
 S         SS jjrSS jr   S         SS jjr    SS jr      SS jr S     S S jjr    S!S jrS"S jr S#         S$S jjrSrU =r$ )%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:

.. 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

NrD   proxyrG   proxy_configc                   > [         TU ]  U5        X0l        U   [        U5      U l        [
        U l        [        R                  5       U l        g N)super__init__connection_pool_kwr   poolspool_classes_by_schemekey_fn_by_schemera   )self	num_poolsr\   r~   	__class__s       rX   r}   PoolManager.__init__   sB     	!"4*95
 '=# 0 5 5 7rW   c                    U $ r{   rO   r   s    rX   	__enter__PoolManager.__enter__   s    rW   c                $    U R                  5         g)NF)clear)r   exc_typeexc_valexc_tbs       rX   __exit__PoolManager.__exit__   s     	

rW   c                "   U R                   U   nUc  U R                  R                  5       nUR                  S5      c	  [        US'   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	blocksize)rZ   r[   portrt   )r   r~   ra   re   rk   ri   SSL_KEYWORDS)r   rZ   r[   r   rm   pool_clsro   kws           rX   	_new_poolPoolManager._new_pool   s      .2-H-H-P""55::<O {+3+=OK( .CT* . V"##B- # 6o66rW   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)r   r   r   s    rX   r   PoolManager.clear  s     	

rW   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.rt   rZ   P   r   r[   )r   _merge_pool_kwargsr   re   rb   connection_from_context)r   r[   r   rZ   pool_kwargsrm   s         rX   connection_from_host PoolManager.connection_from_host  sv    " $%9::11+>$*$4f!!%%oh&?&E&E&GLD"&"&++O<<rW   c                   SU;   a,  [         R                  " S[        5        UR                  S5        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.
strictzdThe 'strict' parameter is no longer needed on Python 3+. This will raise an error in urllib3 v2.1.0.rZ   rm   )	warningswarnDeprecationWarningri   rb   r   re   r   connection_from_pool_key)r   rm   rZ   pool_key_constructorpool_keys        rX   r   #PoolManager.connection_from_context1  s     &MM>"
 ) *002#4488@#"6**'8,,X,WWrW   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.
NrZ   r[   r   r   )r   lockre   r   )r   r   rm   poolrZ   r[   r   s          rX   r   $PoolManager.connection_from_pool_keyJ  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.
)r   rZ   r   )r   r   r[   r   rZ   )r   urlr   us       rX   connection_from_urlPoolManager.connection_from_urld  s:     cN((FFk ) 
 	
rW   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.
)r~   ra   rd   KeyError)r   overridebase_pool_kwargsro   values        rX   r   PoolManager._merge_pool_kwargsv  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)rx   r   ry   rZ   )r   
parsed_urls     rX   !_proxy_requires_url_absolute_form-PoolManager._proxy_requires_url_absolute_form  s:     ::2JJ)):+<+<
 
 	
rW   c                   [        U5      nUR                  c  [        R                  " S[        SS9  U R                  UR                  UR                  UR                  S9nSUS'   SUS'   S	U;  a  U R                  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*                  (       ak  UR-                  U5      (       dU  US	   R/                  5       n
US	    H5  nUR1                  5       U	R*                  ;   d  M#  U
R3                  US5        M7     XS	'    U	R5                  XXvS9n	XS'   X4S'   [<        R?                  SX(5        UR;                  5         U R                  " X40 UD6$ ! [6         a'    U	R8                  (       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.
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   rZ   Fassert_same_hostredirectr\   i/  GETbodyretries)r   )response_poolzRedirecting %s -> %s) r   rZ   r   r   r   r   r[   r   r\   r   urlopenrequest_uriget_redirect_locationr   statusr   _prepare_for_method_changere   
isinstancer   from_intremove_headers_on_redirectis_same_hostra   rb   ri   	incrementr   raise_on_redirect
drain_connloginfo)r   methodr   r   r   r   connr   redirect_locationr   new_headersheaders               rX   r   PoolManager.urlopen  s5    cN88MMA , ((affQXX(N!&:B LLByM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
 Y-,,.KY-<<>W%G%GGOOFD1 ( (yM	''h'SG  9!:'@||F<<<  	((##%O		s   "H3 3.I$#I$)r~   r   r   r   )
   N)r   intr\   typing.Mapping[str, str] | Noner~   
typing.AnyreturnNone)r   r   )r   ztype[BaseException] | Noner   zBaseException | Noner   zTracebackType | Noner   ztyping.Literal[False]r{   )
rZ   r,   r[   r,   r   r   rm   dict[str, typing.Any] | Noner   r   )r   r   Nrt   N
r[   r5   r   r/   rZ   r5   r   r   r   r   )rm   dict[str, typing.Any]r   r   )r   r*   rm   r   r   r   )r   r,   r   r   r   r   )r   r   r   r   )r   r   r   boolT
r   r,   r   r,   r   r   r   r   r   r   )rP   rQ   rR   rS   rT   rx   rU   ry   r}   r   r   r   r   r   r   r   r   r   r   r   rV   __classcell__r   s   @rX   r   r      s   B E:'+L$+ 3788 18 )	8
 
8 8", & %	
 
 9=$7$7 $7 	$7
 6$7 
$7L  #48== = 	=
 2= 
=:X4X	X22G	6 EI

%A
	
$ 4 	 ,
 7;P=P= #P=/3P=BLP=	P= P=rW   r   c                     ^  \ rS rSrSr       S                   S	U 4S jjjr   S
         SU 4S jjjr S     SS jjr S         SU 4S j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.

: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

c	                B  > [        U[        5      (       a)  UR                   SUR                   SUR                   3n
OU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        [        UUUU5      U l        U R                  U	S'   U R                  U	S'   U R                  U	S'   [        TU ]@  " X#40 U	D6  g )	Nz://:rs   r   )r   _proxyr]   _proxy_config)r   r   rZ   r[   r   r   r   r   re   _replacerx   proxy_headersproxy_ssl_contextr
   ry   r|   r}   )r   	proxy_urlr   r\   r   r   use_forwarding_for_httpsproxy_assert_hostnameproxy_assert_fingerprintr~   str_proxy_urlrx   r   r   s                rX   r}   ProxyManager.__init__#  s
    i!344(//0INN3C1Y^^DTUM%M-(<<00$U\\22zz!%%ellB7DNNN-E
*0b!2'$!$	
 (,zz8$/3/A/A+,.2.?.??+B/ABrW   c                   > US:X  a  [         TU ]  XX4S9$ [         TU ]  U R                  R                  U R                  R                  U R                  R
                  US9$ )Nru   )r   )r|   r   rx   r[   r   rZ   )r   r[   r   rZ   r   r   s        rX   r   !ProxyManager.connection_from_hostL  se     W7/F 0   w+JJOOTZZ__djj.?.?[ , 
 	
rW   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)r   r   r\   headers_r   s        rX   _set_proxy_headersProxyManager._set_proxy_headers\  s<     e$3&&%VOOG$rW   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'   [        TU ]$  " X4SU0UD6$ )z@Same as HTTP(S)ConnectionPool.urlopen, ``url`` must be absolute.r\   r   )
r   r   rx   ry   rZ   re   r\   r  r|   r   )r   r   r   r   r   r   r\   r   s          rX   r   ProxyManager.urlopenm  sn     cN.tzz4;L;LahhWW ffY5G 33CAByMwvDXDDDrW   )rx   ry   r   r   )r   NNNFNN)r   r,   r   r   r\   r   r   r   r   r@   r   r   r   z"None | str | typing.Literal[False]r   r5   r~   r   r   r   r   r   r{   )r   r,   r\   r   r   ztyping.Mapping[str, str]r   r   )rP   rQ   rR   rS   rT   r}   r   r  r   rV   r   r   s   @rX   r   r     sA   4r 379=37).DH/3'C'C 'C 1	'C
 7'C 1'C #''C  B'C #-'C )'C 
'C 'CX  #48

 
 	

 2
 

 
" DH!@	!$ 7;EE #E/3EBLE	E ErW   r   c                    [        SSU 0UD6$ )Nr   rO   )r   )r   r   s     rX   r   r   |  s    ,#,,,rW   )rl   ztype[PoolKey]rm   r   r   r*   )r   r,   r   r   r   r   ):
__future__r   	functoolsloggingtypingr   typesr   urllib.parser   _collectionsr   r   _request_methodsr	   
connectionr
   connectionpoolr   r   r   
exceptionsr   r   r   r   r   r   util.connectionr   
util.proxyr   
util.retryr   util.timeoutr   util.urlr   r   TYPE_CHECKINGssltyping_extensionsr   __all__	getLoggerrP   r   r   rk   
NamedTupler*   rr   partialr   r   r   r   r   rO   rW   rX   <module>r     s   "        ? , # S S  ' 1 7  ! $	&
; !   $f $N4 4 /D4 4 x 5w?6@ 
 #5?RS G=. G=T
ME; ME`-rW   