
    $hz                     V    S r SSKrSSKJrJr  SSKJr   " S S\R                  5      r	g)z*The module containing HTTPProxyDigestAuth.    N)cookiesutils   )_digest_auth_compatc                      ^  \ rS rSrSr\R                  " S\R                  S9rU 4S jr	\
S 5       r\R                  S 5       rU 4S jrS	 rS
 rSrU =r$ )HTTPProxyDigestAuth
   a7  HTTP digest authentication between proxy

:param stale_rejects: The number of rejects indicate that:
    the client may wish to simply retry the request
    with a new encrypted response, without reprompting the user for a
    new username and password. i.e., retry build_digest_header
:type stale_rejects: int
zdigest )flagsc                 \   > [         [        U ]
  " U0 UD6  SU l        U R	                  5         g )Nr   )superr   __init__stale_rejectsinit_per_thread_state)selfargskwargs	__class__s      `/var/www/html/shao/venv/lib/python3.13/site-packages/requests_toolbelt/auth/http_proxy_digest.pyr   HTTPProxyDigestAuth.__init__   s,    !414B6B""$    c                 R    [        U SS 5      nUc  U R                  $ UR                  $ N_thread_localgetattr_stale_rejectsr   )r   thread_locals     r   r   !HTTPProxyDigestAuth.stale_rejects   s.    t_d;&&&)))r   c                 >    [        U SS 5      nUc  Xl        g Xl        g r   r   )r   valuer   s      r   r   r   "   s"    t_d;"').&r   c                 L   >  [         [        U ]  5         g ! [         a     g f = f)N)r   r   r   AttributeError)r   r   s    r   r   )HTTPProxyDigestAuth.init_per_thread_state*   s(    	%tBD 		s    
##c                 V   UR                   S:X  Ga  U R                  S:  Ga  UR                  R                  S5      nUc  [	        S5      eU R
                  R                  U5      (       d  U$ [        R                  " U R
                  R                  SUSS95      U l
        SUR                  R                  ;   as  S	U R                  ;   ac  U R                  S	   R                  5       S
:X  a  U =R                  S-  sl        O,U R                  S	   R                  5       S:X  a  [	        S5      eUR                    UR                  5         UR                  R                  5       n[         R"                  " UR$                  UR                  UR&                  5        UR)                  UR$                  5        U R+                  UR,                  UR.                  5      UR                  S'   UR0                  R2                  " U40 UD6nUR4                  R7                  U5        XEl        U$ U$ )zzHandle HTTP 407 only once, otherwise give up

:param r: current response
:returns: responses, along with the new response
i     zproxy-authenticatezRproxy server violated RFC 7235:407 response MUST contain header proxy-authenticate r   )countProxy-AuthorizationstaletruefalsezUser or password is invalid)status_coder   headersgetIOError_patmatchr   parse_dict_headersubchalrequestlowercontentclosecopyr   extract_cookies_to_jar_cookiesrawprepare_cookiesbuild_digest_headermethodurl
connectionsendhistoryappend)r   rr   s_authprep_rs         r   
handle_407HTTPProxyDigestAuth.handle_4071   s    ==CD$6$6$:YY]]#78F~JK K YY__V,,//		b&24DI
 &):)::tyy(99W%++-7&&!+&YYw'--/7:!"?@@ IIGGI99>>#D**4==!))QUUK  /262J2JTXX3'DLL./""4262BJJa JIHr   c                     U R                  5         U R                  (       a3  U R                  UR                  UR                  5      UR
                  S'   UR                  SU R                  5        U$ )Nr(   response)r   
last_noncer>   r?   r@   r-   register_hookrI   )r   rE   s     r   __call__HTTPProxyDigestAuth.__call___   sU    ""$??/3/G/G!%%0AII+, 	

DOO4r   )r   r4   r   )__name__
__module____qualname____firstlineno____doc__recompile
IGNORECASEr0   r   propertyr   setterr   rI   rO   __static_attributes____classcell__)r   s   @r   r   r   
   sf     ::j6D% * * / /,\ r   r   )
rU   rV   requestsr   r   r&   r   authHTTPDigestAuthr    r   r   <module>ra      s%    0 	 # )]$-- ]r   