
    6he                       S SK J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JrJrJrJrJrJr  SSKJrJr  \R,                  r\R.                  r\R0                  r\R2                  rS&S jr " S	 S
5      r " S S\R8                  5      rS r\" \S5      r " S S\R@                  5      rS r! " S S\RD                  5      r# " S S\#5      r$\(       a:  S'S jr% " S S\R@                  5      r& " S S\RN                  \RP                  5      r( " S S\RR                  5      r) " S S\RT                  5      r*S r+ " S S \RX                  5      r- " S! S"\RX                  5      r./ r/       S(S# jr0S)S$ jr1S% r2g)*    )annotationsN   )_)hex)encodingerrorhttpconnection	keepalivepycompatsslutilurllibcompatutil)
stringutilurlutilc                    U R                  SS5      n U R                  SS5      n U R                  SS5      n U(       a  U R                  SS5      n U $ )	a  Replace special characters "&", "<" and ">" to HTML-safe sequences.
If the optional flag quote is true, the quotation mark character (")
is also translated.

This is the same as cgi.escape in Python, but always operates on
bytes, whereas cgi.escape in Python 3 only works on unicodes.
   &s   &amp;   <s   &lt;   >s   &gt;   "s   &quot;)replace)squotes     //usr/lib/python3/dist-packages/mercurial/url.pyescaper   '   sL     	
		$!A			$ A			$ AIIdI&H    c                  2    \ rS rSrS rS rS rS rS rSr	g)	passwordmgr7   c                    Xl         X l        g N)uipasswddb)selfr!   r"   s      r   __init__passwordmgr.__init__8   s     r   c                :    U R                   R                  XX45      $ r    )r"   add_password)r#   realmuriuserpasswds        r   r'   passwordmgr.add_password<   s    }}))%dCCr   c                j   [        U[        S 5      [        45      (       d   e[        U[        5      (       d   eU R                  R	                  X5      nUu  pE[
        R                  " U5      [
        R                  " U5      pTU(       aD  U(       a=  U R                  XE5        [
        R                  " U5      [
        R                  " U5      4$ U(       a  U(       dk  [        R                  " U R                  X$5      nU(       aC  Uu  pxUR                  S5      UR                  S5      pTU R                  R                  SU-  5        U(       a  U(       Gd  [        R                  " [
        R                  " U5      5      n	S U	l        U R                  R#                  5       (       d?  [$        R&                  " [)        S5      [        R*                  " [-        U	5      5      -  5      eU R                  R/                  [)        S5      [        R*                  " [-        U	5      5      -  5        U R                  R/                  [)        S5      [
        R                  " U5      -  5        U(       a(  U R                  R/                  [)        S5      U-  5        O#U R                  R1                  [)        S5      S S	9nU(       d  U R                  R3                  5       nUc  g
U R                  R5                  XXE5        U R                  XE5        [
        R                  " U5      [
        R                  " U5      4$ )Ns   usernames   password#   using auth.%s.* for authentication
s"   http authorization required for %ss#   http authorization required for %s
s
   realm: %s
s	   user: %s
s   user:)default)NN)
isinstancetypestrr"   find_user_passwordr   bytesurl_writedebugstrurlhttpconnectionmodreadauthforurir!   getdebugr   urlqueryinteractiver   Abortr   hidepasswordbyteswritepromptgetpassr'   )
r#   r(   authuriauthinfor*   r+   resgroupauthus
             r   r3   passwordmgr.find_user_password?   sB   %$t*c!23333'3''''==33EC((.0A0A&0IfFT*OOD)8??6+BCC6#22477GJC!#xx4dhh{6KfEMN6H--g67AAG77&&((kk;<**5845 
 GGMM9:&&uQx01 GGMM!N+h.?.?.FFGa.56ww~~ak4~@* <""54@&%xv'>??r   c                    [        S5      nU R                  R                  X1U=(       a    S[        U5      -  =(       d    S4-  5        g )N    http auth: user %s, password %s
   *   not set)r   r!   r:   len)r#   r*   r+   msgs       r   r5   passwordmgr._writedebugp   s8    45c6#@dS[.@#NJOOPr   c                :    U R                   R                  S U5      $ r    )r"   r3   )r#   rD   s     r   find_stored_password passwordmgr.find_stored_passwordt   s    }}//g>>r   )r"   r!   N)
__name__
__module____qualname____firstlineno__r$   r'   r3   r5   rS   __static_attributes__ r   r   r   r   7   s    !D/@bQ?r   r   c                       \ rS rSrS rS rSrg)proxyhandlerx   c                N   UR                  SS5      =(       d    [        R                  R                  S5      nU(       Ga  UR	                  S5      (       d  UR	                  S5      (       d  SU-   S-   n[
        R                  " U5      nUR                  (       d.  UR                  SS5      Ul        UR                  SS5      Ul        S	S
/nUR                  UR                  SS5       Vs/ s H  oUR                  5       PM     sn5        UR                  [        R                  R                  SS5      R                  S5       Vs/ s H8  nUR                  5       (       d  M  UR                  5       R                  5       PM:     sn5        UR                  SS5      (       a  / U l        OX@l        [!        U5      nX"S.nUR#                  S[
        R$                  " ['        U5      5      -  5        O0 n[(        R*                  R-                  X5        Xl        g s  snf s  snf )Ns
   http_proxys   hosts   http:s   https:s   http://   /s   users   passwds	   localhosts	   127.0.0.1s   nos   no_proxyr      ,s   always)httphttpss   proxying through %s
)configr   environr9   
startswithr   r;   r*   r+   extend
configlistlowersplitstrip
configboolno_listr2   r:   r?   r@   urlreqr\   r$   r!   )r#   r!   proxyurlproxyrl   pproxiess          r   r$   proxyhandler.__init__y   s   99]G4 
8H8H8L8L9

  ##H--1D1DY1O1O%047KK)E::YY}g>
!yy	B $\2GNN$&MM-$GH$Gq$GH NN &--11+sCII$OOwwy &AGGIOO%O }}]I66!& 5zH';GHH(7+?+?e+MM G$$T35 Is   -H	H"&"H"c                   [         R                  " [        R                  " U5      5      R	                  S5      S   nU R
                   Hn  nXE:X  a    g UR                  S5      (       a  UR                  USS  5      (       a    g UR                  S5      (       d  MS  UR                  USS  5      (       d  Mn    g    [        R                  R                  XX#5      $ )N   :r   s   *.      .r   )r   r4   r   gethostri   rl   re   endswithrm   r\   
proxy_open)r#   reqro   type_hostes         r   ry   proxyhandler.proxy_open   s      !5!5c!:;AA$GJAy||E""t}}QqrU';';||D!!dmmAabE&:&:  ""--dFFr   )rl   r!   N)rU   rV   rW   rX   r$   ry   rY   rZ   r   r   r\   r\   x   s    .`
Gr   r\   c                   ^  U 4S jnU$ )Nc                   > [        U[        R                  5      (       a7  UR                  S5        [        R
                  " U5       H  nT" X5        M     g T" X5        g Nr   )r0   r7   httpsendfileseekr   filechunkiter)r#   datachunkorgsends      r   	_sendfile _gen_sendfile.<locals>._sendfile   sI    d-::;;IIaL++D1$ 2 Dr   rZ   )r   r   s   ` r   _gen_sendfiler      s      r   httpshandlerc                  L    \ rS rSr\" \R                  R                  5      rSrg)r	      rZ   N)	rU   rV   rW   rX   r   r
   HTTPConnectionsendrY   rZ   r   r   r	   r	      s    11667Dr   r	   c                d   UR                   nU(       a  US S S;  a  SU-   nSnO[        R                  " U5      nSnU(       d  U[        R                  " U5      :X  a  [        R
                  " [        R                  " U5      5      nU(       d  UR                  S:X  a  SR                  UR                  UR                  =(       d    S/5      Ul        UR                  R                  5       Ul        UR                  R                  U R                   R"                  5        g S Ul        S Ul        g )	N   )zhttp://zhttps:/zhttps://TFs   httpsrt   s   443)_tunnel_hostr   getselector
getfullurlr   r;   r   r4   schemejoinr|   portrealhostportheaderscopyupdateparent
addheaders)handlerhrz   tunnel_host
new_tunnelrI   s         r   _generic_start_transactionr      s    ""Kr?"88${2K
"..s3
[L$;$;C$@@KK))+67X-!YY1A6'CDAN((*AIIIW^^667ANAIr   c                       \ rS rSrS rS rSrg)httphandler   c                .    U R                  [        U5      $ r    )do_openr	   )r#   rz   s     r   	http_openhttphandler.http_open   s    ||NC00r   c                Z    [        XU5        [        R                  R                  XU5      $ r    )r   r
   HTTPHandler_start_transactionr#   r   rz   s      r   r   httphandler._start_transaction   s%    "4C0$$77EEr   rZ   N)rU   rV   rW   rX   r   r   rY   rZ   r   r   r   r      s    1Fr   r   c                  8   ^  \ rS rSrSrU 4S jrU 4S jrSrU =r$ )logginghttphandler   z%HTTP(S) handler that logs socket I/O.c                J   > [         TU ]  " U0 UD6  Xl        X l        X0l        g r    )superr$   _logfh_logname_observeropts)r#   logfhnameobserveroptsargskwargs	__class__s         r   r$   logginghttphandler.__init__   s%    $)&))r   c                   >^^^ U R                   mU R                  mU R                  m " UUU4S jSU5      n[        TU ]  " U/UQ70 UD6$ )Nc                  0   >^  \ rS rSrU UUU4S jrSrU =r$ )9logginghttphandler.do_open.<locals>.logginghttpconnection   c                r   > [         TU ]  5         [        R                  " TU R                  T40 TD6U l        g r    )r   connectr   makeloggingsocketsock)r#   r   r   r   r   s    r   r   Alogginghttphandler.do_open.<locals>.logginghttpconnection.connect   s2    ! 22DIIx3@	r   )r   )rU   rV   rW   rX   r   rY   __classcell__)r   r   r   r   s   @r   logginghttpconnectionr      s     r   r   )r   r   r   r   r   )	r#   
http_classr   r   r   r   r   r   r   s	        @@@r   r   logginghttphandler.do_open   sM    ==**	 	J 	 w4FtFvFFr   )r   r   r   )	rU   rV   rW   rX   __doc__r$   r   rY   r   r   s   @r   r   r      s    /*G Gr   r   httpsconnectionc                .  ^	 U R                   nU Vs0 s HV  nUR                  5       R                  S5      (       d  M)  [        R                  " U5      [        R                  " X   5      _MX     nnU R
                  nU R                  SU-  5        UR                  5        H  nU R                  SU-  5        M     U R                  S5        U R                  U R                  U R                  S9m	 T	R                  5       u  pgnU[        R                  :w  a  O[        [        U	4S jS5      5        MC  US:X  a*  [        [        T	R                   R"                  S5      5        g U R%                  5         ['        S	XxR)                  5       4-  5      es  snf )
Nzproxy-s   CONNECT %s HTTP/1.0
s   %s: %s
s   
)methodc                 T   > T R                   R                  5       R                  5       $ r    )fpreadlinerj   )rF   s   r   <lambda>&_generic_proxytunnel.<locals>.<lambda>%  s    cffoo/557r   r      zTunnel connection failed: %d %s)r   rh   re   r   bytestrr   r   itemsresponse_classr   _method_read_statushttplibCONTINUElistiterr   r   closeOSErrorrj   )
r#   r   xproxyheadersr   headerversionstatusreasonrF   s
            @r   _generic_proxytunnelr     sZ   ,, 
wwy##H- >HQ!1!1'*!== 	 

 ((		,|;<"((*FIImf,- +		' !!$))DLL!A &)&6&6&8#GV)))7=>  S=cffoow/0JJL1V\\^4LL E
s
   (F1Fc                      \ rS rSr\R
                  r\R                  r	\
" \R                  5      r\R                  " \R                  5      r   SS jrS rSrg)r   i0  Nc                f    [         R                  R                  " XU/UQ70 UD6  X0l        X@l        g r    )r
   r   r$   key_file	cert_file)r#   r|   r   r   r   r   r   s          r   r$   httpsconnection.__init__7  s.     $$--d$PPP$M&Nr   c                   [         R                  " U R                  U R                  4U R                  5      U l        U R                  nU R                  nU(       a   [        U 5        UR                  SS5      S   n[        R                  " U R
                  U R                  U R                  U R                  US9U l        [        R                  " U R
                  5        g )Nrt   r   r   )r!   serverhostname)socketcreate_connectionr|   r   timeoutr   r   r   rsplitr   
wrapsocketr   r   r!   validatesocket)r#   r|   r   s      r   r   httpsconnection.connectD  s    00DII&DI 99D,,L$T*#**43A6**		77#DI ""499-r   )r   r   r   )NNN)rU   rV   rW   rX   r
   HTTPResponser   r   
HTTPS_PORTdefault_portr   safesendr   wrapgetresponser   getresponser$   r   rY   rZ   r   r   r   r   0  sS    "//))Y//0//0F0FG
 	'	.r   c                  4    \ rS rSrSS jrS rS rSS jrSrg)	r   iW  Nc                    [         R                  R                  XS9  [        R                  R                  U 5        Xl        [        U R
                  U R
                  R                  5      U l        g )Nr   )	r
   KeepAliveHandlerr$   rm   r   r!   r   httppasswordmgrdbpwmgr)r#   r!   r   s      r   r$   httpshandler.__init__X  sN    &&///F((.G$TWWdgg.G.GHDJr   c                Z    [        XU5        [        R                  R                  XU5      $ r    )r   r
   r   r   r   s      r   r   httpshandler._start_transaction^  s%    &t4--@@#NNr   c                P   [         R                  " U5      nU R                  R                  U5      u  p4[        R
                  " U R                  X#5      nU(       a)  Uu  pgXpl        U R                  R                  SU-  5        OS U l        U R                  U R                  U5      $ )Nr.   )r   r   r  rS   r7   r8   r!   rH   r:   r   _makeconnection)r#   rz   r;   r*   passwordrF   rG   rH   s           r   
https_openhttpshandler.https_openb  s     ))#.C!ZZ<<SAND#22477CFC! 	EMN 	<< 4 4c::r   c                H   S nS n[        U5      S:  a  US   n[        U5      S:  a  US   nUSS  nU R                  (       a>  SU R                  ;   a.  SU R                  ;   a  U R                  S   nU R                  S   n[        XXV/UQ70 UD6nU R                  Ul        U$ )Nr   r   ru   s   keys   cert)rO   rH   r   r!   )r#   r|   r   r   r   keyfilecertfileconns           r   r  httpshandler._makeconnectionp  s    GH4yA~q'4yA~78D yyVtyy0W		5I))F+99W-"G048>D ggDGKr   )rH   r  r!   r    )	rU   rV   rW   rX   r$   r   r  r  rY   rZ   r   r   r   r   W  s    	I	O	;	r   c                  &    \ rS rSrS rS rS rSrg)httpdigestauthhandleri  c                Z    [         R                  R                  " U /UQ70 UD6  S U l        g r    )rm   r  r$   retried_reqr#   r   r   s      r   r$   httpdigestauthhandler.__init__  s(    $$--dDTDVDr   c                    g r    rZ   r#   s    r   reset_retry_count'httpdigestauthhandler.reset_retry_count       	r   c                z    X0R                   La  X0l         SU l        [        R                  R	                  XX#U5      $ r   )r  retriedrm   r  http_error_auth_reqedr#   auth_headerr|   rz   r   s        r   r  +httpdigestauthhandler.http_error_auth_reqed  s;    &&&"DL++AAt'
 	
r   )r  r  N)rU   rV   rW   rX   r$   r  r  rY   rZ   r   r   r  r    s     
r   r  c                  8    \ rS rSrS rS rS rS rS rS r	Sr
g	)
httpbasicauthhandleri  c                h    S U l         [        R                  R                  " U /UQ70 UD6  S U l        g r    )rH   rm   r!  r$   r  r  s      r   r$   httpbasicauthhandler.__init__  s/    	##,,TCDCFCr   c                t    U R                   (       a&  UR                  U R                  U R                   5        U$ r    rH   add_unredirected_headerr  r#   requests     r   http_request!httpbasicauthhandler.http_request  (    99++D,<,<diiHr   c                t    U R                   (       a&  UR                  U R                  U R                   5        U$ r    r%  r'  s     r   https_request"httpbasicauthhandler.https_request  r+  r   c                    g r    rZ   r  s    r   r  &httpbasicauthhandler.reset_retry_count  r  r   c                z    X0R                   La  X0l         SU l        [        R                  R	                  XX#U5      $ r   )r  r  rm   r!  r  r  s        r   r  *httpbasicauthhandler.http_error_auth_reqed  s;    &&&"DL**@@t'
 	
r   c                   U R                   R                  U[        R                  " U5      5      u  pEUb  S[        R
                  " U5      [        R
                  " U5      4-  nS[        R                  " [        R                  " U5      R                  5       5      -  nUR                  U R                  S 5      U:X  a  g Xpl        UR                  U R                  U5        U R                  R                  U5      $ g )Ns   %s:%szBasic %s)r+   r3   r   r   r   r4   r6   base64	b64encoderj   
get_headerr  rH   r&  r   open)r#   r|   rz   r(   r*   pwrawrH   s           r   retry_http_basic_auth*httpbasicauthhandler.retry_http_basic_auth  s    ;;11<**3/
 >h//5x7H7H7LMMC0@0@0E0K0K0M NND~~d..5=I''(8(8$?;;##C((r   )rH   r  r  N)rU   rV   rW   rX   r$   r)  r-  r  r  r:  rY   rZ   r   r   r!  r!    s      

r   r!  c                   U R                  SS5      nU(       d  g [        R                  " U5      n [        R                  R	                  [
        R                  " U5      5      nUR                  5         U$ ! [        R                  R                   a=  nU R                  [        S5      U[        R                  " U5      4-  5         S nAg S nAff = f)Ns   auths
   cookiefiles?   (error loading cookie file %s: %s; continuing without cookies)
)rc   r   
expandpath	cookielibMozillaCookieJarr   fsdecodeload	LoadErrorwarnr   r   forcebytestr)r!   
cookiefile	cookiejarr}   s       r   load_cookiejarrG    s    7M2J,J
NN33j)
	 	>>## 

 :22156	7	
 	

s   AA7 7C3CCc                      \ rS rSrS r\rSrg)readlinehandleri  c                <     " S SUR                   5      nX2l         U$ )Nc                      \ rS rSrSS jrSrg)7readlinehandler.http_response.<locals>.readlineresponsei  c                    Sn/ n U R                  5       nU(       d   U$ UR                  U5        U[        U5      -  nU(       a  X!:  a   U$ MJ  r   )r   appendrO   )r#   sizehinttotalr   lines        r   	readlinesAreadlinehandler.http_response.<locals>.readlineresponse.readlines  sX    ==?D
 	 KK%SY&EE$5 r   rZ   N)r   )rU   rV   rW   rX   rR  rY   rZ   r   r   readlineresponserL    s    r   rT  r   )r#   r(  responserT  s       r   http_responsereadlinehandler.http_response  s!    	x11 	 .r   rZ   N)rU   rV   rW   rX   rV  https_responserY   rZ   r   r   rI  rI    s    $ #Nr   rI  c                  V    \ rS rSr\R
                  \R                  S.rS rS r	\	r
Srg)digesthandleri  )s   sha256s   sha512c                   SU;  a  [         R                  " [        S5      5      eUR                  S5      u  p#X R                  ;  a"  [         R                  " [        S5      U-  5      eX0l        U R                  U   " 5       U l        g )Nrt   s   invalid digest specifications    unsupported digest algorithm: %s)r   r>   r   ri   digest_algorithms_digest_hasher)r#   digestalgochecksums       r   r$   digesthandler.__init__   so    v++a ?@AAd+---++a CDtKLL--d35r   c                     " S SUR                   5      nX2l         U R                  Ul        SUl        U R                  R	                  5       Ul        SUl        SUl        U$ )Nc                  V   ^  \ rS rSrS rSU 4S jjrU 4S jrU 4S jrU 4S jrSr	U =r
$ )	3digesthandler.http_response.<locals>.digestresponsei
  c                   U R                   R                  U5        U =R                  [        U5      -  sl        U R                  (       a  [        U R                   R                  5       5      nX R                  :w  aa  [        R                  " [        S5      [        R                  " U R                  5      [        R                  " U5      U R                  4-  5      eg g )Ns7   file with digest %s expected, but %s found for %d bytes)r^  r   _digest_consumedrO   _digest_finishedr   r_  r]  r   SecurityErrorr   r   r   )r#   r   r_  s      r   _digest_inputAdigesthandler.http_response.<locals>.digestresponse._digest_input  s    ##D)%%T2%(( !4!4!67F-#11 Z !) 0 0 > ( 0 0 8 $ 5 5	 	 . )r   c                   > U =R                   S-  sl         [        TU ]	  U5      nU =R                   S-  sl         U R                   S:X  a  U R                  U5        U$ Nr   r   )_digest_recursion_levelr   readrj  )r#   amtr   r   s      r   ro  8digesthandler.http_response.<locals>.digestresponse.read  sT    ,,1,w|C(,,1,//14&&t,r   c                   > U =R                   S-  sl         [        TU ]	  5       nU =R                   S-  sl         U R                   S:X  a  U R                  U5        U$ rm  )rn  r   r   rj  )r#   r   r   s     r   r   <digesthandler.http_response.<locals>.digestresponse.readline$  sS    ,,1,w'),,1,//14&&t,r   c                   > U =R                   S-  sl         [        TU ]	  U5      nU =R                   S-  sl         U R                   S:X  a  U R                  US U 5        U$ rm  )rn  r   readintorj  )r#   destgotr   s      r   ru  <digesthandler.http_response.<locals>.digestresponse.readinto,  s[    ,,1,g&t,,,1,//14&&tDSz2
r   c                .   > SU l         [        TU ]	  5       $ )NT)rh  r   r   )r#   r   s    r   _close_conn?digesthandler.http_response.<locals>.digestresponse._close_conn4  s    (,%w}&r   )rh  r    )rU   rV   rW   rX   rj  ro  r   ru  rz  rY   r   r   s   @r   digestresponsere  
  s!    "' 'r   r|  r   F)r   r]  rg  r^  r   rn  rh  )r#   r(  rU  r|  s       r   rV  digesthandler.http_response	  s[    ,	'X// ,	'\ ,<<$%!<<,,.+,($)!r   )r]  r^  N)rU   rV   rW   rX   hashlibsha256sha512r\  r$   rV  rX  rY   rZ   r   r   rZ  rZ    s,     >>>>
66p #Nr   rZ  c           	        U R                  [        SS5      n/ n	U(       a$  U	R                  [        X4U=(       d    0 US95        OU	R                  [	        US95        [
        (       a  U	R                  [        XS95        U	R                  [        U 5      5        [        X R                  5      n
Ubm  Uu  ppU
R                  US   5      u  nnX:w  d  U(       a  U
R                  XX5        U R                  SX=(       a    S[        U5      -  =(       d    S4-  5        U	R                  [        U
5      [!        U
5      45        U	R                  ["         Vs/ s H  nU" X
5      PM     sn5        U	R                  [$        R'                  [)        U 5      S95        U	R                  [+        5       5        U(       a  U	R                  [-        U5      5        [$        R.                  " U	6 nSUl        SUl        SUl        U(       d7  S	[6        R8                  " 5       -  nS
[:        R<                  " U5      4/Ul        OS
[:        R<                  " U5      4/Ul        U(       a  UR>                  R                  S5        U$ s  snf )a  
construct an opener suitable for urllib2
authinfo will be added to the password manager

The opener can be configured to log socket events if the various
``logging*`` arguments are specified.

``loggingfh`` denotes a file object to log events to.
``loggingname`` denotes the name of the to print when logging.
``loggingopts`` is a dict of keyword arguments to pass to the constructed
``util.socketobserver`` instance.

``sendaccept`` allows controlling whether the ``Accept`` request header
is sent. The header is sent by default.
s   https   timeoutr   r   rL   rM   rN   )rF  s"   mercurial/proto-1.0 (Mercurial %s)z
User-agent)Acceptzapplication/mercurial-0.1) 
configwithfloatrN  r   r   	has_httpsr   r\   r   r   rS   r'   r:   rO   rf   r!  r  handlerfuncsrm   httpcookieprocessorrG  rI  rZ  buildopenerrequestscountsentbytescountreceivedbytescountr   r   r   sysstrr   )r!   rE   	useragent	loggingfhloggingnameloggingopts
sendacceptr_  r   handlerspassmgrr(   urisr*   r+   	saveduser	savedpassr   openeragents                       r   r  r  G  s   2 mmE7J7GH(9r7	
 	G45y-	
 OOL$%"223G$,!T&;;DGD	9  d;
02s6{ 2@jAB	

 OO	g	&(=g(FG OO\:\Qr^\:;OOF..9K.LMOOO%&f-.*F FF !F" 5F*HOOE,BCD*HOOI,FGH   !HIMQ ;s   I=c                   [         R                  " U5      nUR                  (       a2  UR                  R                  5       Ul        UR	                  5       u  pOl[
        R                  " [
        R                  " U5      5      nS[        R                  " [        R                  [        R                  " U5      5      5      -   nS n[        XX4S9R                  [        R                  " U5      U5      $ )Ns   file://)r  r_  )r   r;   r   rh   rE   r   normpathabspathr   r4   rm   pathname2urlr@  r  r7  r6   )r!   url_r   r  r_  rI   rE   paths           r   r7  r7    s    DAxx88>>#h}}T\\$/0H-- 1 1$ 78
 
 ":EJJt r   c                Z   ^ U R                   m " U4S jSU R                  5      nXl        g)zWrap a response object with common error handlers.

This ensures that any I/O from any consumer raises the appropriate
error and messaging.
c                  &   > \ rS rSrSU 4S jjrSrg)!wrapresponse.<locals>.readerproxyi  Nc                  >  T" U5      $ ! [         R                   as  nUR                  (       a4  [        UR                  5      nUR                  U-   n[        S5      XC4-  nO[        S5      n[        R                  " U[        S5      S9eS nAf[         R                   a/  n[        R                  " [        S5      U-  [        S5      S9eS nAff = f)NsB   HTTP request error (incomplete response; expected %d bytes got %d)s(   HTTP request error (incomplete response)sv   this may be an intermittent network failure; if the error persists, consider contacting the network or server operator)hints   HTTP request error (%s))	r   IncompleteReadexpectedrO   partialr   r   PeerTransportErrorHTTPException)r#   sizer}   rw  rP  rP   origreads         r   ro  &wrapresponse.<locals>.readerproxy.read  s    ~%)) ::aii.CJJ,E5 %C
 GHC..6  (( ..01A56 s!    CA.BC$*CCrZ   r    )rU   rV   rW   rX   ro  rY   )r  s   r   readerproxyr    s    	 	r   r  N)ro  r   )respr  r  s     @r   wrapresponser    s&     yyH dnn  D !Nr   r    )r#   r   )NNN   sNTN)NTN)3
__future__r   r4  r~  r   i18nr   noder    r   r   r	   r7   r
   r   r   r   r   utilsr   r   r   stringiourlerrrm   r   r   r\   r   hasattrr  r   r   r   r   r   r   r   r   r   r  r!  rG  basehandlerrI  rZ  r  r  r7  r  rZ   r   r   <module>r     s}   #     	 	 	
 ,,==		 >? >?B;G6&& ;G| FN+	8Y-- 8,F)'' FG G2 &P%.)22 %.N-y1163F3F -`
F88 
*.666 .b
*#f(( #,I#F&& I#X 
 bJ *!r   