+
    :1j9                    8   R t ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIH	t	 ^ RI
Ht ^RIHt ^RIHt ^R	IHt ^R
IHt ^RIHtHtHtHt ^RIHtHtHt ^RIHt ^RIH t  ^RIH!t!H"t"H#t#H$t$H%t%H&t&H't'H(t(H)t) ^RI*H+t+ ^RI,H-t- ^RI.H/t/ ^RI0H1t1 ]'       d	   ^ RI2H3t3H4t4 ]! ]54      t6^t7]8! R'4      t9]8! . R(O4      t:]8! . R)O4      t;]8! . R*O4      t< ! R R]"4      t=R R lt>R R lt?]R R l4       t@R R ltA ! R R ]B4      tC ! R! R"]%]CR#7      tD ! R$ R%]!4      tER&# )+z>Requests session configured with all accepted scheme adapters.)annotations)fnmatch)cache)	getLogger)local)TYPE_CHECKING)
CondaError)dals)CONDA_HOMEPAGE_URL)context)add_username_and_passwordget_proxy_username_and_passsplit_anaconda_tokenurlparse)OfflineErrorPluginError
ProxyErrorChannel)read_binstar_tokens)	AuthBaseBaseAdapterCaseInsensitiveDictRetrySession_basic_auth_strextract_cookies_to_jarget_auth_from_urlget_netrc_auth)
FTPAdapter)HTTPAdapter)LocalFSAdapter)	S3Adapter)PreparedRequestRequestc                  (    ] tR t^ctR R ltR tRtR# )EnforceUnusedAdapterc                   V ^8  d   QhRR/# )   requestr$    )formats   "Alib/python3.14/site-packages/conda/gateways/connection/session.py__annotate__!EnforceUnusedAdapter.__annotate__d   s     
 
G 
    c                	4    \        R VP                   R24      h)z%EnforceUnusedAdapter called with url z<.
This command is using a remote connection in offline mode.)r   url)selfr)   argskwargss   &&*,r,   sendEnforceUnusedAdapter.sendd   s'    3GKK= AI I
 	
r/   c                	    \        4       hN)NotImplementedError)r2   s   &r,   closeEnforceUnusedAdapter.closej   s    !##r/   r*   N)__name__
__module____qualname____firstlineno__r5   r:   __static_attributes__r*   r/   r,   r&   r&   c   s    
$r/   r&   c                    V ^8  d   QhRRRR/# )r(   r1   strreturnz
str | Noner*   )r+   s   "r,   r-   r-   n   s     0 03 0: 0r/   c                B    \         P                  ! V 4      P                  # )zG
Given a URL, determine the channel it belongs to and return its name.
)r   from_urlcanonical_name)r1   s   &r,   get_channel_name_from_urlrG   n   s     C ///r/   c                    V ^8  d   QhRRRR/# )r(   headersdictrC   Noner*   )r+   s   "r,   r-   r-   u   s     ! !d !t !r/   c                   V P                  4        F  w  rVP                  4       pV\        9   d   \        RV R24      hVP	                  R4      '       g   VP	                  R4      '       d   \        RV R24      hV\
        9   g   Ky  \        V\        4      '       g   K  VP                  4       \        9   g   K  \        RV RV R24      h	  R	# )
a  
Validate plugin-provided headers and raise PluginError if any forbidden
headers are detected. This prevents plugins from compromising conda's
core network stack.

:param headers: Dictionary of headers to validate
:raises PluginError: If any forbidden headers are detected
z*Plugin attempted to set forbidden header 'z'. This header is not allowed as it could compromise conda's network stack. See https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_request_headerzproxy-zsec-z'. Headers starting with 'Proxy-' or 'Sec-' are not allowed as they could compromise conda's network stack. See https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_request_headerz Plugin attempted to set header 'z' with forbidden method 'z'. This method override is not allowed as it could compromise conda's network stack. See https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_request_headerN)	itemslowerFORBIDDEN_HEADERSr   
startswith!FORBIDDEN_METHOD_OVERRIDE_HEADERS
isinstancerB   FORBIDDEN_HTTP_METHODS)rI   keyvalue	key_lowers   &   r,   _validate_plugin_headersrW   u   s     mmo
IIK	))<SE Ba a  ))Y-A-A&-I-I<SE Ba a  99%%%%++-;Q*Q!6se;TUZT[ \e e ) &r/   c                   V ^8  d   QhRR/# )r(   r1   rB   r*   )r+   s   "r,   r-   r-      s     .= .=S .=r/   c                   \        V 4      pVf   \        4       # / p\        P                   F  pVP	                  RR4      pWA8X  d   TpK  \        V 4      p\        V4      pVP                  VP                  8w  d   KR  VP                  VP                  ,           pVP                  VP                  ,           p\        Wx4      '       g   K  TpK  	  VP	                  RR4      P                  4       ;'       g    Rp	V	f   \        4       # \        P                  P                  V	4      p
V
'       g   \        4       # \        V
! V4      R7      # )zh
Function that determines the correct Session object to be returned
based on the URL that is passed in.
Nchannel auth)r\   )rG   CondaSessionr   channel_settingsgetr   schemenetlocpathr   stripplugin_managerget_auth_handler)r1   channel_namer^   settingsrZ   
parsed_urlparsed_settingurl_without_schemapatternauth_handlerauth_handler_clss   &          r,   get_sessionrn      s(    -S1L ~ ,,,,y"-"' c]
!'*   J$5$55'..@ ''.*=*==%//'' -* $''399;CCtL ~-->>|L~-l;<<r/   c                   V ^8  d   QhRR/# )r(   rC   rB   r*   )r+   s   "r,   r-   r-      s     S SS Sr/   c                    V f   R# \        V \        4      '       d   \        V 4      # \        V 4      pVP                   RVP
                   RV P                   2# )zW
Function that determines which storage key to use for our CondaSession object caching
default.z::)rR   tuplehashtyper=   r>   rf   )r\   	auth_types   & r,   get_session_storage_keyrw      sX     |$DzT
I""#1Y%;%;$<Bt?P?P>QRRr/   c                  8   a  ] tR t^tRtV 3R ltV 3R ltRtV ;t# )CondaSessionTypez
Takes advice from https://github.com/requests/requests/issues/1871#issuecomment-33327847
and creates one Session instance per thread.
c                	>   < \        4       VR &   \        SV `	  WW#4      # )_thread_local)r   super__new__)mcsnamebasesdct	__class__s   &&&&r,   r}   CondaSessionType.__new__   s     $wOws%55r/   c                	F  < \        VP                  R 4      4      p V P                  P                  V,          #   \         d'    \
        ST `  ! R/ TB pY#/T P                  n         T# \         d-    \
        ST `  ! R/ TB ;q0P                  P                  T&    T# i ; i)r\   r*   )rw   r_   r{   sessionsAttributeErrorr|   __call__KeyError)clsr4   storage_keysessionr   s   &,  r,   r   CondaSessionType.__call__   s    -fjj.@A	$$--k:: 	@g&00G*5)?C&   	@E@P AA G''00= 	s   : -B *B 3)B B r*   )	r<   r=   r>   r?   __doc__r}   r   r@   __classcell__r   s   @r,   ry   ry      s    
6 r/   ry   c                  T   a  ] tR t^tRR V 3R llltR V 3R llt]R 4       tRtV ;t	# )r]   c                   V ^8  d   QhRR/# )r(   r\   z!AuthBase | tuple[str, str] | Noner*   )r+   s   "r,   r-   CondaSession.__annotate__   s     ;0 ;0/;0r/   c                  < \         SV `  4        T;'       g    \        4       V n        V P                  P                  \        P                  4       Rp\        P                  R8X  d-    ^ RI	p^ RI
pVP                  VP                  4      pRT n        M\        P                  V n        \        P                   '       dT   \#        4       pV P%                  RV4       V P%                  RV4       V P%                  RV4       V P%                  RV4       M\'        \        P(                  \        P*                  . ROR	R	R
7      p\-        WbR7      pV P%                  RV4       V P%                  RV4       V P%                  R\/        4       4       V P%                  R\1        4       4       V P%                  R\3        4       4       \        P4                  V P6                  R&   \        P8                  '       d(   \        P:                  \        P8                  3V n        R# \        P:                  '       d   \        P:                  V n        R# R#   \         d    \        R4      hi ; i)zI
:param auth: Optionally provide ``requests.AuthBase`` compliant objects
N
truststorezNThe `ssl_verify: truststore` setting is only supported onPython 3.10 or later.Tzhttp://zhttps://zftp://zs3://F)totalbackoff_factorstatus_forcelistraise_on_statusrespect_retry_after_header)max_retriesssl_contextzfile://z
User-Agent)i  i  i  i  )r|   __init__CondaHttpAuthr\   proxiesupdater   proxy_servers
ssl_verifysslr   
SSLContextPROTOCOL_TLS_CLIENTImportErrorr   verifyoffliner&   mountr   remote_max_retriesremote_backoff_factorr    r   r"   r!   
user_agentrI   client_ssl_cert_keyclient_ssl_certcert)	r2   r\   r   r   r   unused_adapterretryhttp_adapterr   s	   &&      r,   r   CondaSession.__init__   s    	++MO	G112-
!(33C4K4KL DK!,,DK???13NJJy.1JJz>2JJx0JJw/ 00&<<!5 %+0E '5RLJJy,/JJz<0JJx.JJw	,

9n./%,%7%7\"&&& 00'2M2MNDI$$$//DI %K   , s   *#I Ic                    V ^8  d   QhRRRR/# )r(   r)   r$   rC   r#   r*   )r+   s   "r,   r-   r   2  s     0 0w 0? 0r/   c                	  < \        VP                  4      pVP                  R9   d   \        P                  P                  VP                  R7      p\        P                  P                  VP                  VP                  R7      p\        V4       \        V4       \        / VCVCVP                  ;'       g    / C4      Vn        \        SV `5  V4      # )https)host)r   rb   )r   http)r   r1   r`   r   rd   get_cached_session_headersra   get_cached_request_headersrb   rW   r   rI   r|   prepare_request)r2   r)   r1   session_headersrequest_headersr   s   &&   r,   r   CondaSession.prepare_request2  s    w{{#::**%44OOZZ P O &44OOZZchh P O
 %_5$_51% & ,,"	GO w&w//r/   c                	t     V P                   P                  P                  4        R #   \         d     R # i ; ir8   )r{   r   clearr   )r   s   &r,   cache_clearCondaSession.cache_clearK  s1    	&&,,. 		s   $( 77)r\   r   r   r8   )
r<   r=   r>   r?   r   r   classmethodr   r@   r   r   s   @r,   r]   r]      s,    ;0 ;0z0 02  r/   r]   )	metaclassc                  L    ] tR tRtR t]R 4       t]R 4       t]R 4       tRt	R# )r   iT  c                	    \         P                  VP                  4      Vn        V P                  V4       VP	                  R V P
                  4       V# )response)r   add_binstar_tokenr1   _apply_basic_authregister_hook
handle_407)r2   r)   s   &&r,   r   CondaHttpAuth.__call__W  s?    #55gkkBw'j$//:r/   c                	   \        V P                  4      p\        V4      '       d   TMR pVf   \        V P                  4      p\	        V\
        4      '       d'   \        V4      ^8X  d   \        V!  V P                  R&   V # )NAuthorization)	r   r1   anyr   rR   rs   lenr   rI   )r)   url_authr\   s   &  r,   r   CondaHttpAuth._apply_basic_auth]  sc     %W[[1x==xd<!'++.DdE""s4yA~/>/EGOOO,r/   c                	H   \        V 4      w  rV'       g   \        P                  '       dw   \        4       P	                  4        FZ  w  r2VP                  V4      '       g   K  \        P                  R V4       ^RIH	p V! V4      pW%n
        VP                  RR7      u # 	  V # )z"Adding anaconda token for url <%s>r   T)with_credentials)r   r   add_anaconda_tokenr   rM   rP   logdebugmodels.channelr   tokenr1   )r1   	clean_urlr   binstar_urlr   rZ   s   &     r,   r   CondaHttpAuth.add_binstar_tokenl  s    /4	333&9&;&A&A&C"''44IIBIN9%i0G$)M";;;== 'D 
r/   c           	        V P                   R8w  d   V # V P                   V P                  4        VP                  R4      p\	        V P
                  4      P                  pW29  d!   \        \        RV: R\         R24      4      hW#,          p\        V4      w  rV\        WEV4      p\        WV4      pWBV&   W!R&   V P                  P                  4       p\        VP                   V P                  V P"                  4       VP%                  VP                   4       WxP&                  R&   V P(                  P*                  ! V3/ VB p	V	P,                  P/                  V 4       Wn        V	# )a  
Prompts the user for the proxy username and password and modifies the
proxy in the session object to include it.

This method is modeled after
  * requests.auth.HTTPDigestAuth.handle_401()
  * requests.auth.HTTPProxyAuth
  * the previous conda.fetch.handle_proxy_407()

It both adds 'username:password' to the proxy URL, as well as adding a
'Proxy-Authorization' header.  If any of this is incorrect, please file an issue.

i  r   z(
            Could not find a proxy for z. See
            z/docs/html#configure-conda-for-use-behind-a-proxy-server
            for more information on how to configure proxies.
            zProxy-Authorization)status_codecontentr:   popr   r1   r`   r   r	   r
   r   r   r   r)   copyr   _cookiesrawprepare_cookiesrI   
connectionr5   historyappend)
r   r4   r   proxy_scheme	proxy_urlusernamepasswordproxy_authorization_headerprep	_responses
   &,        r,   r   CondaHttpAuth.handle_407z  sO   $ 3&O 	**Y'-44&((4'7 8  !  )	8F-i8L	%4X%H" )#y$$&t}}h.>.>MT]]+.H*+'',,T<V<	  * r/   r*   N)
r<   r=   r>   r?   r   staticmethodr   r   r   r@   r*   r/   r,   r   r   T  sC         8 8r/   r   N)r   r   ftps3file)zaccept-charsetzaccept-encodingzaccess-control-request-headerszaccess-control-request-methodr   zcontent-lengthcookiedatedntexpectr   z
keep-aliveoriginrefererz
set-cookietetrailerztransfer-encodingupgradevia)zx-http-methodzx-http-method-overridezx-method-override)connecttracetrack)Fr   
__future__r   r   	functoolsr   loggingr   	threadingr   typingr   r[   r   
auxlib.ishr	   base.constantsr
   base.contextr   
common.urlr   r   r   r   
exceptionsr   r   r   r   r   anaconda_clientr   r   r   r   r   r   r   r   r   r   adapters.ftpr   adapters.httpr    adapters.localfsr!   adapters.s3r"   requests.modelsr#   r$   r<   r   RETRIES	frozensetCONDA_SESSION_SCHEMESrO   rQ   rS   r&   rG   rW   rn   rw   ru   ry   r]   r   r*   r/   r,   <module>r     s   E "         0 #  @ ? % 1
 
 
 % & , "8
 "   2 %.% ! ##@A $; $0!H .= .=bSt 4]7&6 ]@_H _r/   