+
    BiK                       ^ RI 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	t	^ RI
t
^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHtHtHtHtHtHtHtHt ^ R	IHt ^ RIt^ RIt]P@                  ! R
R7        ! R R] PB                  4      t" ! R R] PB                  4      t# ! R R4      t$ ! R R4      t% ! R R]&4      t' ! R R]
PP                  4      t) ! R R4      t* ! R R4      t+ ! R R]
PX                  4      t- ! R R4      t. ! R  R!4      t/R" t0R# t1 ! R$ R%]Pd                  Pf                  4      t4 ! R& R']Pd                  Pj                  4      t6]7! ]Pp                  R(4      '       d     ! R) R*]Pd                  Pr                  4      t: ! R+ R,]Pd                  Pj                  4      t; ! R- R.4      t< ! R/ R0] PB                  4      t= ! R1 R2] PB                  4      t> ! R3 R4] PB                  4      t?] P                  ! ]P                  ! 4       R54      tB ! R6 R7] PB                  4      tC ! R8 R9] PB                  4      tD]ER:8X  d   ] P                  ! 4        R# R# );    N)support)	os_helper)requires_subprocess)warnings_helper)test_urllib)mock)RequestOpenerDirectorHTTPBasicAuthHandlerHTTPPasswordMgrWithPriorAuth_parse_proxy_proxy_bypass_winreg_override_proxy_bypass_macosx_sysconfAbstractDigestAuthHandler)urlsplitT)modulec                   8   a  ] tR t^'t o R tR tR tR tRtV t	R# )TrivialTestsc                    R Fm  p/ p\        RV,          V4       VR VP                  4        F>  w  r4V P                  VP                  RV,          V: RV: RVP                  : 24       K@  	  Ko  	  R# )requestzfrom urllib.%s import *__builtins__z	urllib.%sz is exposed in 'urllib.z' but defined in N)r   responseparseerrorrobotparser)execitemsassertEqual
__module__)selfr   contextkvs   &    (/usr/lib/python3.14/test/test_urllib2.pytest___all__TrivialTests.test___all__)   sg    LFG*V3W='  {V/C./ (	 M    c                X   V P                  \        P                  P                  4       V P	                  \
        \        P                  P                  R 4       \        P                  P                  \        P                  P                  4      P                  \        P                  R4      p\        P                  R8X  d   RV,          pM	RV,          p\        P                  P                  V4      ;_uu_ 4       pVP                  4        RRR4       R#   + '       g   i     R# ; i)z	bogus url/ntz
file:///%sz	file://%sN)
addCleanupurllibr   
urlcleanupassertRaises
ValueErrorurlopenospathabspath__file__replacesepnameread)r    fnamefile_urlfs   &   r$   test_trivialTrivialTests.test_trivial4   s     	112*fnn&<&<kJ  7 78@@M77d?#e+H"U*H^^##H--FFH .---s   =DD)	c                    R . RO3RRR.3R. RO3R. R	O3.pV F4  w  r#V P                  \        P                  P                  V4      V4       K6  	  R# )
za,b,czpath"o,l"og"i"cal, examplezpath"o,l"og"i"calexampleza, b, "c", "d", "e,f", g, hza="b\"c", d="e\,f", g="h\\i"N)abc)r@   rA   z"c"z"d"z"e,f"gh)za="b"c"zd="e,f"zg="h\i")r   r,   r   parse_http_list)r    testsstringlists   &   r$   test_parse_http_list!TrivialTests.test_parse_http_listG   sb    o&),?+KL*8://12 "LFV^^;;FCTJ "r'   c                    \         P                  P                  R 4      pV P                  VP                  \        V4      4       R# )reasonN)r,   r   URLErrorassertInrL   str)r    errs   & r$   test_URLError_reasonstr$TrivialTests.test_URLError_reasonstrR   s,    ll##H-cjj#c(+r'    N)
__name__r   __qualname____firstlineno__r%   r<   rI   rQ   __static_attributes____classdictcell____classdict__s   @r$   r   r   '   s     	/&	K, ,r'   r   c                   8   a  ] tR t^Wt o R tR tR tR tRtV t	R# )RequestHdrsTestsc                    RpV P                  \        VRR/R7      P                  R,          R4       V P                  \        VRR/R7      P                  R,          R4       R# )a  
The Request.headers dictionary is not a documented interface.  It
should stay that way, because the complete set of headers are only
accessible through the .get_header(), .has_header(), .header_items()
interface.  However, .headers pre-dates those methods, and so real code
will be using the dictionary.

The introduction in 2.4 of those methods was a mistake for the same
reason: code that previously saw all (urllib2 user)-provided headers in
.headers now sees only a subset.

http://example.com	Spam-eggsblahheadersz	spam-EggSN)r   r	   rb   )r    urls   & r$   test_request_headers_dict*RequestHdrsTests.test_request_headers_dictY   si     #*5v)>##*7;89?	A 	*5v)>##*7;89?	Ar'   c                   Rp\        VRR/R7      pV P                  VP                  R4      4       V P                  VP	                  4       R.4       VP                  RR4       V P                  \        VP	                  4       4      RR.4       V P                  VP                  R4      4       V P                  VP                  R4      4       V P                  VP                  RR4      R4       VP                  R4       V P                  VP                  R4      4       VP                  R	R
4       V P                  VP                  R	4      4       VP                  R	4       V P                  VP                  R	4      4       R# )a  
Note the case normalization of header names here, to
.capitalize()-case.  This should be preserved for
backwards-compatibility.  (In the HTTP case, normalization to
.title()-case is done by urllib2 before sending headers to
http.client).

Note that e.g. r.has_header("spam-EggS") is currently False, and
r.get_header("spam-EggS") returns None, but that could be changed in
future.

Method r.remove_header should remove items both from r.headers and
r.unredirected_hdrs dictionaries
r^   r_   r`   ra   zFoo-Barbazz	Not-theredefaultzUnredirected-spamEggsN)r_   r`   )zFoo-barrg   )r	   
assertTrue
has_headerr   header_items
add_headersortedassertFalseassertIsNone
get_headerremove_headeradd_unredirected_header)r    rc   reqs   &  r$   test_request_headers_methods-RequestHdrsTests.test_request_headers_methodsn   s>    #cK#89{34))+.C-DEy%( 0 0 23,.CD	F45#..56Y?K+&45##$7@':;<-.(;<=r'   c                   \         P                  P                  4       pVP                  pVP                  pV! R RRR4       V! R RRR4       V! R RRR4       V! R R	R
R4       V! R RRR4       V P                  V! R R4      R.4       V P                  V! R R4      R.4       V P                  V! R R4      R.4       V P                  V! R R4      R.4       V P                  V! R R4      R.4       V P                  V! R R4      R.4       V! RRRR4       V! RRRR4       V! RRRR4       V P                  V! RR4      R/4       V P                  V! RR4      R04       V P                  V! RR4      R/4       V P                  V! RR4      R/4       V P                  V! RR4      R/4       V P                  V! RR4      R14       V! RRR R!4       V P                  V! RR"4      R14       V P                  V! RR4      R24       V P                  V! RR#4      R24       V! R$RR%R&4       V! R$RR'R(4       V P                  V! R$R4      R34       V! R)RR*R)4       V P                  V! R)R4      R44       V P                  V! R)R+4      R14       V P                  V! R R,4      R14       V P                  V! R R-4      R54       V P                  V! R R4      R54       V P                  V! R R	4      R64       V P                  V! R R4      R74       R# )8z
Some Realmhttp://example.com/joepasswordzhttp://example.com/ninizhttp://c.example.com:31283rB   zd.example.com4dze.example.com:31285eexample.comr^   zhttp://example.com/spamzhttp://example.com/spam/spamzhttp://example.com/foofoozhttp://example.com/barbarninizhttp://example.com/foo/barfoobarnibarzhttp://example.com/foo/zhttp://example.com/foo/bazzhttp://example.com/foobarNzhttp://example.com/baz/rg   nininizhttp://example.com/bazzhttp://example.com/baz/barrA   firstr`   secondspamr@   1zhttp://a.example.com/zc.example.comzc.example.com:3128)ry   rz   )r   r{   )r   r   NN)rg   r   )r   r   )r   r@   )r|   rB   )r}   r~   )r   r   r,   r   HTTPPasswordMgradd_passwordfind_user_passwordr   r    mgraddfind_user_passs   &   r$   test_password_manager&RequestHdrsTests.test_password_manager   s`   nn,,.//L/
CL14>L5sC@L/34L.S9 	mD,	.6MN,	.6JK,	.6KL,	.(AC,	. 	(FH,	. 	C)5$7C)5&9C-xA-EF&	(-EF(	*-FG&	(-IJ&	(-IJ&	(-HI%	' 	C*E8<-EF%	'-FG*	,-IJ*	,
 	C&8C&&9-BC+	-
 	C%sC0-BC#	% 	-DE%	'
 	oF%	'6JK#	%<)DE	 	oF#	%6JK#	%r'   c                   \         P                  P                  4       pVP                  pVP                  pV! RRRR4       V! RRRR4       V! R	R
RR4       V! RRRR4       V P                  V! RR4      R4       V P                  V! RR4      R 4       V P                  V! RR4      R4       V P                  V! RR4      R4       V P                  V! RR4      R 4       V P                  V! RR4      R 4       V P                  V! RR4      R!4       V P                  V! RR4      R!4       V P                  V! RR4      R!4       V P                  V! R	R4      R4       V P                  V! R	R
4      R"4       V P                  V! R	R4      R"4       V P                  V! RR4      R#4       V P                  V! RR4      R4       V P                  V! RR4      R#4       V P                  V! RR4      R4       R# )$z
The point to note here is that we can't guess the default port if
there's no scheme.  This applies to both add_password and
find_user_password.
r;   zhttp://g.example.com:8010jrC   zhttp://h.example.com11r"   rD   zi.example.com:8012lizj.example.com13mzg.example.com:100Nzg.example.com:80zg.example.comzhttp://g.example.com:100zhttp://g.example.comzh.example.comzh.example.com:80zhttp://h.example.com:80zi.example.comzhttp://i.example.com:80zj.example.com:80zhttp://j.example.comzhttp://j.example.com:80r   )r   r   )r   r"   )r   r   )r   r   r   r   s   &   r$   "test_password_manager_default_port3RequestHdrsTests.test_password_manager_default_port   s    nn,,.//C*D#6C's3C#T3/C$,-@A%	'-?@$	&_=%	'-GH%	'-FG$	&-CD$	&_={K-?@+N-FG$	&_=|L-?@+N-FG$	&_={K-?@%	'-CD$	&-FG%	'r'   rS   N)
rT   r   rU   rV   rd   ru   r   r   rW   rX   rY   s   @r$   r\   r\   W   s"     A*">HT%l'' ''r'   r\   c                   L   a  ] tR tRt o . tR]P                  3R ltR tRt	V t
R# )
MockOpeneri  Nc                0    WVuV n         V n        V n        R # N)rt   datatimeout)r    rt   r   r   s   &&&&r$   openMockOpener.open  s    ,/w)$)T\r'   c                "    WuV n         V n        R # r   )protoargs)r    r   r   s   &&*r$   r   MockOpener.error  s     %
DIr'   )r   r   r   rt   r   )rT   r   rU   rV   
addheaderssocket_GLOBAL_DEFAULT_TIMEOUTr   r   rW   rX   rY   s   @r$   r   r     s$     J!6+I+I ?, ,r'   r   c                   :   a  ] tR tRt o RR ltRR ltR tRtV tR# )MockFilei  Nc                    R # r   rS   r    counts   &&r$   r8   MockFile.read      r'   c                    R # r   rS   r   s   &&r$   readlineMockFile.readline   r   r'   c                    R # r   rS   r    s   &r$   closeMockFile.close#  r   r'   rS   r   )	rT   r   rU   rV   r8   r   r   rW   rX   rY   s   @r$   r   r     s      r'   r   c                   &   a  ] tR tRt o R tRtV tR# )MockHeadersi'  c                4    \        V P                  4       4      # r   )rH   values)r    r7   s   &&r$   
getheadersMockHeaders.getheaders(  s    DKKM""r'   rS   N)rT   r   rU   rV   r   rW   rX   rY   s   @r$   r   r   '  s     # #r'   r   c                   6   a  ] tR tRt o RR ltR tR tRtV tR# )MockResponsei,  Nc                ~    \         P                  P                  W4       WW53w  V n        V n        V n        V n        R # r   )ioStringIO__init__codemsgrb   rc   )r    r   r   rb   r   rc   s   &&&&&&r$   r   MockResponse.__init__-  s/    
T(6:6M3	48T\48r'   c                    V P                   # r   ra   r   s   &r$   infoMockResponse.info1  s    ||r'   c                    V P                   # r   rc   r   s   &r$   geturlMockResponse.geturl4      xxr'   )r   rb   r   rc   r   )	rT   r   rU   rV   r   r   r   rW   rX   rY   s   @r$   r   r   ,  s     N r'   r   c                   ,   a  ] tR tRt o R tR tRtV tR# )MockCookieJari8  c                    Wn         R # r   )ach_req)r    r   s   &&r$   add_cookie_headerMockCookieJar.add_cookie_header9  s    r'   c                "    W!uV n         V n        R # r   )ec_reqec_r)r    r   r   s   &&&r$   extract_cookiesMockCookieJar.extract_cookies<  s    !(TYr'   )r   r   r   N)rT   r   rU   rV   r   r   rW   rX   rY   s   @r$   r   r   8  s     3 3r'   r   c                   ,   a  ] tR tRt o R tR tRtV tR# )
FakeMethodi@  c                *    Wn         W0n        W n        R # r   )	meth_namehandleaction)r    r   r   r   s   &&&&r$   r   FakeMethod.__init__A  s    "r'   c                T    V P                   ! V P                  V P                  .VO5!  # r   )r   r   r   )r    r   s   &*r$   __call__FakeMethod.__call__F  s     {{4>>4;;>>>r'   )r   r   r   N)rT   r   rU   rV   r   r   rW   rX   rY   s   @r$   r   r   @  s     
? ?r'   r   c                   8   a  ] tR tRt o R tR tR tR tRtV t	R# )MockHTTPResponseiJ  c                D    Wn         W n        W0n        W@n        ^V n        R# )   N)fpr   statusrL   r   )r    r   r   r   rL   s   &&&&&r$   r   MockHTTPResponse.__init__K  s    	r'   c                    R # ) rS   r   s   &r$   r8   MockHTTPResponse.readR  s    r'   c                    / # r   rS   r   s   &r$   r   MockHTTPResponse.infoU  s    	r'   c                    V P                   # r   r   r   s   &r$   r   MockHTTPResponse.geturlX  r   r'   )r   r   r   rL   r   N)
rT   r   rU   rV   r   r8   r   r   rW   rX   rY   s   @r$   r   r   J  s      r'   r   c                   t   a  ] tR tRt o R t]P                  3R ltR tRR lt	RRR/R	 llt
R
 tR tRtV tR# )MockHTTPClassi\  c                Z    ^ V n         . V n        RV n        RV n        RV n        / V n        R# )r   NF)levelreq_headersr   raise_on_endheaderssock_tunnel_headersr   s   &r$   r   MockHTTPClass.__init__]  s/    
	#( 	!r'   c                    Wn         W n        V # r   )hostr   )r    r  r   s   &&&r$   r   MockHTTPClass.__call__e  s    	r'   c                    Wn         R # r   )r   )r    r   s   &&r$   set_debuglevelMockHTTPClass.set_debuglevelj  s    
r'   Nc                r    Wn         W n        V'       d	   W0n        R # V P                  P                  4        R # r   )_tunnel_host_tunnel_portr   clear)r    r  portrb   s   &&&&r$   
set_tunnelMockHTTPClass.set_tunnelm  s)      #*   &&(r'   encode_chunkedFc                  Wn         W n        Ve(   V ;P                  VP                  4       ,          un        V P                  P	                  4        V'       d   W0n        WPn        V P                  '       d   \        4       hR # r   )	methodselectorr   r   sortr   r  r   OSError)r    r  rc   bodyrb   r  s   &&&&&$r$   r   MockHTTPClass.requestu  sa    /I,###)O $r'   c                .    \        \        4       / ^R4      # )r   OK)r   r   r   s   &r$   getresponseMockHTTPClass.getresponse  s    
BT::r'   c                    R # r   rS   r   s   &r$   r   MockHTTPClass.close  r   r'   )r   r	  r
  r   r  r  r   r  r   r   r  r   r   r   )rT   r   rU   rV   r   r   r   r   r  r  r   r  r   rW   rX   rY   s   @r$   r   r   \  s@     " &,%C%C 
)$; r'   r   c                   H   a  ] tR tRt o RtR tR tR tR tR t	R t
R	tV tR
# )MockHandleri    c                (    V P                  V4       R # r   )_define_methods)r    methodss   &&r$   r   MockHandler.__init__  s    W%r'   c                    V FG  p\        V4      ^8X  d   Vw  r4MTRrC\        W4V P                  4      p\        V P                  W54       KI  	  R# )   N)lenr   r   setattr	__class__)r    r"  specr7   r   meths   &&    r$   r!  MockHandler._define_methods  sE    D4yA~#f#TfdDKK8DDNND/ r'   c                   V P                   P                  P                  WW434       Vf   R # VR8X  d   V # VR8X  d   \        ^R/ R4      pV# VR8X  d   \	        R4      # VP                  R4      '       d[   W"P                  R4      ^,           R  p \        V4      p\        ^R/ R4      pV P                   P                  R	V^ ,          WVR/ 4      # VR
8X  d    \        P                  P                  R4      hQ h  \         d     Lii ; i)Nreturn selfreturn responser  r   return requestzhttp://blah/r    httpraiser`   )parentcallsappendr   r	   
startswithrfindintr/   r   r,   rM   )r    fn_namer   r   kwdsresr   s   &&&*,  r$   r   MockHandler.handle  s     $!<=>}$K((sD"b1CJ''>**w'',,s+A-./D4y sD"b1C;;$$VT!WcRHHw,,''//u  s   C9 9DDc                    R # r   rS   r   s   &r$   r   MockHandler.close  r   r'   c                4    Wn         . V P                   n        R # r   )r3  r4  )r    r3  s   &&r$   
add_parentMockHandler.add_parent  s    r'   c                \    \        VR 4      '       g   R# V P                  VP                  8  # )handler_orderT)hasattrrC  )r    others   &&r$   __lt__MockHandler.__lt__  s)    uo..!!E$7$777r'   )r3  N)rT   r   rU   rV   rC  r   r!  r   r   r@  rF  rW   rX   rY   s   @r$   r  r    s/      M&0.8 8r'   r  c                    . p^ pV Fo  p ! R R\         4      pV! V4      pV;P                  V,          un        VP                  V 4       V^,           pVP                  V4       V P	                  V4       Kq  	  V# )a  Create MockHandlers and add them to an OpenerDirector.

meth_spec: list of lists of tuples and strings defining methods to define
on handlers.  eg:

[["http_error", "ftp_open"], ["http_open"]]

defines methods .http_error() and .ftp_open() on one handler, and
.http_open() on another.  These methods just record their arguments and
return None.  Using a tuple instead of a string causes the method to
perform some action (see MockHandler.handle()), eg:

[["http_error"], [("http_open", "return request")]]

defines .http_error() on one handler (which simply returns None), and
.http_open() on another handler, which returns a Request object.

c                       ] tR tRtRtR# )6add_ordered_mock_handlers.<locals>.MockHandlerSubclassi  rS   NrT   r   rU   rV   rW   rS   r'   r$   MockHandlerSubclassrJ        r'   rL  )r  rC  r@  r5  add_handler)opener	meth_spechandlersr   methsrL  rD   s   &&     r$   add_ordered_mock_handlersrS    st    & HE	+ 	  &	5 	V	1  Or'   c                  N    \        4       pV  F  pVP                  V4       K  	  V# r   )r
   rN  )handler_instancesrO  rD   s   *  r$   build_test_openerrV    s'    F1 Mr'   c                   <   a a ] tR tRt oRV 3R lltR tRtVtV ;t# )MockHTTPHandleri  c                N   < \         \        V `  VR 7       \        4       V n        R# )
debuglevelN)superrX  r   r   httpconn)r    r[  r(  s   &&r$   r   MockHTTPHandler.__init__  s    ot--D%r'   c                :    V P                  V P                  V4      # r   do_openr]  r    rt   s   &&r$   	http_openMockHTTPHandler.http_open  s    ||DMM3//r'   r]  r   )	rT   r   rU   rV   r   rc  rW   rX   __classcell__r(  rZ   s   @@r$   rX  rX    s     (0 0r'   rX  c                   2   a  ] tR tRt o R tR tR tRtV tR# )MockHTTPHandlerRedirecti  c                >    Wn         W n        V P                  4        R # r   )r   rb   reset)r    r   rb   s   &&&r$   r    MockHTTPHandlerRedirect.__init__  s    	

r'   c                "    ^ V n         . V n        R# )r   N)_countrequestsr   s   &r$   rk  MockHTTPHandlerRedirect.reset  s    r'   c                   ^ RI p^ RIpV P                  P                  VP	                  V4      4       V P
                  ^ 8X  d   V P
                  ^,           V n        \        P                  P                  V P                  ,          pVP                  V P                  4      pV P                  P                  RV\        4       V P                  WE4      # Wn        VP                  R4      p\!        ^RVRVP#                  4       4      # )r   Nr1  

r  r   )emailcopyro  r5  deepcopyrn  r1  client	responsesr   message_from_stringrb   r3  r   r   rt   r   get_full_url)r    rt   rs  rt  r7   r   s   &&    r$   rc  !MockHTTPHandlerRedirect.http_open   s    T]]3/0;;!++/DK;;((3D++DLL9C;;$$XZD? ? H++J7CT3C4D4D4FGGr'   )rn  r   rb   rt   ro  N	rT   r   rU   rV   r   rk  rc  rW   rX   rY   s   @r$   ri  ri    s     
H Hr'   ri  HTTPSConnectionc                   <   a a ] tR tRt oRV 3R lltR tRtVtV ;t# )MockHTTPSHandleri  c                N   < \         \        V `  WV4       \        4       V n        R # r   )r\  r~  r   r   r]  )r    r[  r!   check_hostnamer(  s   &&&&r$   r   MockHTTPSHandler.__init__  s    "D2:W)ODMr'   c                :    V P                  V P                  V4      # r   r`  rb  s   &&r$   
https_openMockHTTPSHandler.https_open  s    <<s33r'   re  )NNN)	rT   r   rU   rV   r   r  rW   rX   rf  rg  s   @@r$   r~  r~    s     	,	4 	4r'   r~  c                   2   a  ] tR tRt o R tR tR tRtV tR# )MockHTTPHandlerCheckAuthi  c                     Wn         R V n        R# FNr   has_auth_header)r    r   s   &&r$   r   !MockHTTPHandlerCheckAuth.__init__   s    	$r'   c                    R V n         R# r  )r  r   s   &r$   rk  MockHTTPHandlerCheckAuth.reset$  s
    $r'   c                    VP                  R 4      '       d   RV n        \        P                  P                  V P
                  ,          p\        V P
                  V\        4       RVP                  4       4      # )AuthorizationTr   )	rk   r  r1  rv  rw  r   r   r   ry  )r    rt   r7   s   && r$   rc  "MockHTTPHandlerCheckAuth.http_open'  sS    >>/**#'D {{$$TYY/DIItXZS=M=M=OPPr'   r  Nr{  rY   s   @r$   r  r    s     %%Q Qr'   r  c                   ,   a  ] tR tRt o R tR tRtV tR# )MockPasswordManageri/  c                6    Wn         W n        W0n        W@n        R # r   )realmrc   userrz   )r    r  urir  rz   s   &&&&&r$   r    MockPasswordManager.add_password0  s    
	 r'   c                J    Wn         W n        V P                  V P                  3# r   )target_realm
target_urlr  rz   )r    r  authuris   &&&r$   r   &MockPasswordManager.find_user_password6  s     !!yy$--''r'   )rz   r  r  r  rc   r  N)rT   r   rU   rV   r   r   rW   rX   rY   s   @r$   r  r  /  s     !( (r'   r  c                   J   a  ] tR tRt o R tR tR tR tR tR t	R t
R	tV tR
# )OpenerDirectorTestsi<  c                     ! R  R\         4      pV P                  \        \        4       P                  V! 4       4       R# )c                       ] tR tRtRtR# )<OpenerDirectorTests.test_add_non_handler.<locals>.NonHandleri?  rS   NrK  rS   r'   r$   
NonHandlerr  ?  rM  r'   r  N)objectr.   	TypeErrorr
   rN  )r    r  s   & r$   test_add_non_handler(OpenerDirectorTests.test_add_non_handler>  s/    	 	)(*66
	Fr'   c                    ^ RI Hp \        4       pRR.R..p\        W#4       VP	                  \
        P                  P                  4       4       R F&  pV P                  WP                  VR,           4       K(  	  R# )r   )rM   z://example.com/N)ra  r-  )
proxy_openr-  )redirect_requestr-  )doproxyredirect)
urllib.errorrM   r
   rS  rN  r,   r   UnknownHandlerr.   r   )r    rM   orP  schemes   &    r$   test_badly_named_methods,OpenerDirectorTests.test_badly_named_methodsD  sl     	*')FG01	 	"!/	fnn3356/Fh7H0HI 0r'   c                j   \        4       p. ROR.R.R..p\        W4      p\        R4      pVP                  V4      pV P	                  WS^,          4       V^ ,          R 3V^,          R 3.p\        WaP                  4       F/  w  rxVw  rrV P	                  W3V4       V P	                  W34       K1  	  R# )rc  ftp_openrx   N)rc  r  http_error_302rc  r-  )r
   rS  r	   r   r   zipr4  )r    r  rP  rQ  rt   rr4  expectedgothandlerr7   r   r:  s   &            r$   test_handled OpenerDirectorTests.test_handledY  s    7L)*)*		 -Q:+,FF3K 	QK(1+{+hqk;-GH 0MH(+%G4g_h7T6* 1r'   c                   \        4       p. pR.R3R .^ 33 FD  w  r4 ! R R\        4      pV! V4      pWFn        VP                  V4       VP	                  V4       KF  	  VP                  R4       V P                  VP                  ^ ,          ^ ,          V^,          4       V P                  VP                  ^,          ^ ,          V^ ,          4       R# )rc  r  c                       ] tR tRtRtR# )COpenerDirectorTests.test_handler_order.<locals>.MockHandlerSubclassix  rS   NrK  rS   r'   r$   rL  r  x  s    r'   rL  rx   Nr  )r
   r  rC  r5  rN  r   r   r4  )r    r  rQ  rR  rC  rL  rD   s   &      r$   test_handler_order&OpenerDirectorTests.test_handler_orders  s    'C&Dc%J'2mQ%7%9 Ek  $E*A+OOOAMM!%9 	
$%A4A4r'   c                   \        4       pR.R..p\        W4      p\        R4      pV P                  \        P
                  P                  VP                  V4       V P                  VP                  V^ ,          R V3/ 3.4       R# )rc  rx   N)rc  r2  r  )
r
   rS  r	   r.   r,   r   rM   r   r   r4  )r    r  rP  rQ  rt   s   &    r$   
test_raiseOpenerDirectorTests.test_raise  sz    #$)*	 -Q:+,&,,//=HQKsfb#I"JKr'   c                   \        4       pR.RR .. R	OR..p\        W4      p\        R4      pVP                  V4       \	        VP
                  4      ^8X  g   Q hV^ ,          R V33V^,          RV\        P                  RR/ 33.p\        WQP
                  4       F<  w  rgVw  rp
V P                  W3VR,          4       V P                  W^,          4       K>  	  R# )
rc  r  rx   .  r   :Nr%  NN)rc  z	error 302)http_error_400r2  ))r  r.  http_error_303
http_error)
r
   rS  r	   r   r&  r4  r   	ALWAYS_EQr  r   )r    r  rP  rQ  rt   r4  r  r  r  method_namer   s   &          r$   test_http_error#OpenerDirectorTests.test_http_error  s     '((+6 	 -Q:+,	s177|q   1+{SF31+/))3B79: !0MH)1&G$g3SW=Tq6* 1r'   c                   \        4       pRR.RR..p\        W4      p\        R4      pVP                  V4       V^ ,          R 3V^,          R 3V^ ,          R3V^,          R3.p\	        VP
                  4       F  w  pw  rxrV^8  dT   V P                  Wx3WV,          4       V P                  \        V	4      ^4       V P                  V	^ ,          \        4       Kc  V P                  Wx3WV,          4       V P                  \        V	4      ^4       V P                  V	^ ,          \        4       V	^,          f   K  V P                  V	^,          \        4       K  	  R# )http_requesthttp_responserx   N)r  r/  )r  r.  )
r
   rS  r	   r   	enumerater4  r   r&  assertIsInstancer   )r    r  rP  rQ  rt   r4  r   r  r7   r   r:  s   &          r$   test_processors#OpenerDirectorTests.test_processors  sB   /13/13	 -Q:+,	s a[.)HQK+Ha[/*Xa[/,JL /8.@*A*t1u  '%(;  TA.%%d1gw7   '%(;  TA.%%d1gw7 7&))$q'<@ /Ar'   rS   N)rT   r   rU   rV   r  r  r  r  r  r  r  rW   rX   rY   s   @r$   r  r  <  s2     FJ*+45$L+.!A !Ar'   r  c                     a  ] tR tRt o R t]P                  ! R4      R 4       tR tR t	R t
R t]! 4       R	 4       tR
 tR tR tR tR t]P(                  ! ]! ]P.                  R4      R4      R 4       t]P(                  ! ]! ]P.                  R4      R4      R 4       tR tR tR tR tR tR tR t R t!R t"R t#R t$R t%R t&R  t'R! t(R" t)R# t*R$ t+]P(                  ! ]! ]P.                  R4      R4      R% 4       t,]P(                  ! ]-P\                  R&8H  R'4      R( 4       t/]P(                  ! ]0Pb                  R)8H  R*4      R+ 4       t2R, t3R- t4R. t5R/ t6R0 t7R1 t8R2 t9R3 t:R4 t;R5 t<R6 t=R7t>V t?R8# )9HandlerTestsi  c                  a  ! R  R4      o ! V3R lR\         P                  P                  4      pRpV! V4      p\        4       Vn        RR\
        P                  RRRR	R
.RR3	RR\
        P                  RRRR	R
.RR3	RR\
        P                  RRRR	R
.RR3	RR\
        P                  RRRR	R
.RR3	RR^PRRRR	R
.RR3	RR\
        P                  RRR. RR3	3 EF  w	  rErgrrp\        V4      pRVn        VP                  V4      pV P                  VP                  V4       V P                  VP                  V4       V P                  VP                  \        P                  ! V4      4       V P                  VP                   V4       V P                  VP"                  V
4       V P                  VP$                  P&                  V4       V P                  VP$                  P(                  V	4       VP+                  4       pV P                  VP-                  R4      V4       V P                  \/        VR,          4      \1        V4      4       VP3                  4        EK  	  R# )c                   2   a  ] tR tRt o R tR tR tRtV tR# )-HandlerTests.test_ftp.<locals>.MockFTPWrapperi  c                    Wn         R # r   r   r    r   s   &&r$   r   6HandlerTests.test_ftp.<locals>.MockFTPWrapper.__init__       	r'   c                    WuV n         V n        \        P                  ! V P                  4      \        V P                  4      3# r   )filenamefiletyper   r   r   r&  )r    r  r  s   &&&r$   retrfile6HandlerTests.test_ftp.<locals>.MockFTPWrapper.retrfile  s0    /7,t}{{499-s499~==r'   c                    R # r   rS   r   s   &r$   r   3HandlerTests.test_ftp.<locals>.MockFTPWrapper.close      r'   )r   r  r  N)	rT   r   rU   rV   r   r  r   rW   rX   rY   s   @r$   MockFTPWrapperr    s     !> r'   r  c                   N   <a  ] tR tRt o R t]P                  3V3R lltRtV t	R# )-HandlerTests.test_ftp.<locals>.NullFTPHandleri  c                    Wn         R # r   r  r  s   &&r$   r   6HandlerTests.test_ftp.<locals>.NullFTPHandler.__init__  r  r'   c                   < WuV n         V n        W4uV n        V n        WPn        S! V P
                  4      V n        V P                  # r   )r  passwdr  r  dirsr   
ftpwrapper)r    r  r  r  r  r  r   r  s   &&&&&&&r$   connect_ftp9HandlerTests.test_ftp.<locals>.NullFTPHandler.connect_ftp  s>    )-&	4;'+$	49 	"0";&r'   )r   r  r  r  r  r  r  N
rT   r   rU   rV   r   r   r   r  rW   rX   )rZ   r  s   @r$   NullFTPHandlerr    s     ! %+$B$B' 'r'   r  zrheum rhaponicumz ftp://localhost/foo/bar/baz.html	localhostr   Ir   r   zbaz.htmlz	text/htmlz'ftp://parrot@localhost/foo/bar/baz.htmlparrotz*ftp://%25parrot@localhost/foo/bar/baz.htmlz%parrotz,ftp://%2542parrot@localhost/foo/bar/baz.htmlz	%42parrotzftp://localhost:80/foo/bar/DNzftp://localhost/baz.gif;type=aAzbaz.gifz	image/gifContent-typeContent-length)r,   r   
FTPHandlerr   r3  ftplibFTP_PORTr	   r   r  r   r  r  r  r   gethostbynamer  r  r  r  r  r   getr8  r&  r   )r    r  r   rD   rc   r  r  r  r  type_r  r  mimetypert   r  rb   r  s   &               @r$   test_ftpHandlerTests.test_ftp  s5   		 		
	'V^^66 
	' "4 < 0&//2r3U^Z6 7&//8RU^Z6 :&//9b#U^Z6 <&//;CU^Z6 +"b"cU^R' .&//2r3K)!OJCt6$(( #,CCK

3AQVVT*QXXv.QVVV%9%9$%?@QVVT*QVVT*Q\\22H=Q\\22E:ffhGW[[8(CS)9!:;SYGGGIEOr'   networkc                    ! R  R\         P                  P                  4      p\        P                  ! R4      pV! V4      p\         P                  P                  V4      P                  p V! R4       V P                  R4       R#   \         P                  P                   d<   pT P                  TP                  RTP                  ^ ,           24        Rp?R# Rp?ii ; i)c                   F   a  ] tR tRt o R t]P                  3R ltRtV t	R# )4HandlerTests.test_ftp_error.<locals>.ErrorFTPHandleri  c                    Wn         R # r   
_exception)r    	exceptions   &&r$   r   =HandlerTests.test_ftp_error.<locals>.ErrorFTPHandler.__init__  s    "+r'   c                    V P                   hr   r
  )r    r  r  r  r  r  r   s   &&&&&&&r$   r  @HandlerTests.test_ftp_error.<locals>.ErrorFTPHandler.connect_ftp  s    oo%r'   r
  Nr  rY   s   @r$   ErrorFTPHandlerr    s     , %+$B$B& &r'   r  z.500 OOPS: cannot change directory:/nonexistentzftp://www.pythontest.net/zDid not raise ftplib exceptionzftp error: N)r,   r   r  r  
error_permbuild_openerr   failr   rM   r   rL   r   )r    r  r  rD   r0   raiseds   &     r$   test_ftp_errorHandlerTests.test_ftp_error  s    	&fnn77 	& %%<>	I&..--a055	8/0
 II67	 ||$$ 	@V]]*9>>!+<*=>@ @	@s   ,B C!&0CC!c           	     n
   ^ RI p\        P                  P                  4       p\	        4       ;q2n        \        P                  pRp\        P                  P                  \        P                  P                  V4      RR7      p\        V4      pVP                  '       d   \        P                  ! R4      hVVP!                  RR7      P#                  4       VP!                  \$        P&                  ! R4      R7      P#                  4       .p \$        P&                  ! \$        P(                  ! 4       4      p	V	'       d0   VP-                  VP!                  V	R7      P#                  4       4       V EFN  p
\/        VR	4      p  VP1                  V4       VP3                  4        VP5                  \7        V
4      4      p VP9                  4       pVP;                  4       pVP#                  4       pVP3                  4        \        P<                  ! V4      pVP>                  PA                  VPB                  RR
7      p\        PD                  ! V4       V PG                  W4       V PG                  VR,          R4       V PG                  VR,          R4       V PG                  VR,          V4       V PG                  W4       EKQ  	  VP!                  RR7      P#                  4       RRR\$        P&                  ! R4      : R\        PH                  ! 4       : RV: 2R\        PH                  ! 4       : RV: 23 F  p
 \/        VR	4      p VP1                  V4       VP3                  4        V PK                  \        PL                  PN                  VP4                  \7        V
4      4       \        PD                  ! V4       K  	  \        P                  P                  4       p\	        4       ;q2n        R Fz  w  p
p\7        V
4      p VP5                  V4       V PQ                  VPR                  V4       V PG                  VPT                  R4       V PG                  VPT                  R8H  V4       K|  	  R#   \$        P*                   d    Rp	 ELSi ; i  TP3                  4        i ; i  TP3                  4        i ; i  \        PD                  ! T4       i ; i  TP3                  4        i ; i  \        PD                  ! T4       i ; i  \        PL                  PN                   d    T PW                  T4        Li ; i)r   Ns   hello, world
T)
add_schemeznon-local working directoryr  )netlocr   wb)usegmtr  z
text/plainr  r   zLast-modifiedzlocalhost:80zfile:///file_does_not_exist.txtz)file://not-a-local-host.com//dir/file.txtzfile://z:80r)   z'file://somerandomhost.ontheinternet.comftp))zfile://ftp.example.com//foo.txtF)z file://ftp.example.com///foo.txtF)zfile://ftp.example.com/foo.txtF)z"file://somehost//foo/something.txtF)z#file://localhost//foo/something.txtF),email.utilsr,   r   FileHandlerr   r3  r   TESTFNpathname2urlr1   r2   r3   r   r  unittestSkipTest_replacer   r   r  gethostnamegaierrorr5  r   writer   	file_openr	   r8   r   statutils
formatdatest_mtimeremover   getcwdr.   r   rM   assertIsrt   typero   )r    rs  rD   r  r  towritecanonurlparsedurls	localaddrrc   r;   r  r   rb   respurlstatsmodifiedr  rt   s   &                   r$   	test_fileHandlerTests.test_file%  s   NN&&(!|#H!!#>>..rwwv/FSW.X(#===##$ABBOO;O/668OO6#7#7#DOELLN
	,,V-?-?-ABI KKy9@@BCCVT"A"GGG$GGIKK-668DffhGhhjGGGI ;;11%..1N		&!T+W^4lCW%56=W_5x@W// 4 OO>O299;-7#)#7#7#D#%99;8 YY[&"C
"&GGG$GGI!!&,,"7"7"#++ws|= 		&!'* NN&&(!|#HHC #,C2C  aeeS)  51SXX.4y  	I	 GGI GGI 		&!* GGI
 		&!* <<(( &  %&s   )Q.  R*R6<0R!,AR68S&SAS& T.R	R	RR6!R33R66SS##S&&S>0T43T4c                ,   \         P                  P                  4       p\        4       ;q!n        R pR EF  w  rE\        W5RR/4      pRVn        VP                  RR4       \        4       pVP                  Wv4      pVP                   VP                   VP                   VP                   VP                  VP                  ^8H  R3 VP                  4       p	V	P                    V	P"                   V P%                  VP                  4       V4       V P%                  VP&                  R4       V P%                  VP(                  ^ 4       V P%                  VP*                  V4       V P%                  VP,                  R4       V P%                  VP.                  . RO4       V P%                  VP0                  V4       EK  	  R	Xn        V P5                  \         P6                  P8                  VP                  VX4       \        R R
4      pV P5                  \:        VP<                  V4       R.Vn        R EF  p\        R V4      p\A        ^R/ R4      pVP=                  V4      p
Vf:   V PC                  RVPD                  4       V PC                  RVPD                  4       MFV P%                  VPD                  R,          R4       V P%                  VPD                  R,          R4       V P%                  VPD                  R,          R4       V P%                  VPD                  R,          R4       VP                  RR4       VP                  RR4       VP                  RR4       VP                  RR4       VP=                  V4      p
V P%                  VPD                  R,          R4       V P%                  VPD                  R,          R4       V P%                  VPD                  R,          R4       V P%                  VPD                  R,          R4       EK  	  R# )rx   NFoor   Spameggsr  r   r)   Tbadpostr   r  r  0z!application/x-www-form-urlencodedHostr   rg   ))GETN)POSTs   blahr<  r=  ))
Connectionr   )r;  r   rC  )r'   N)#r,   r   AbstractHTTPHandlerr   r3  r	   r   rs   r   ra  r8   r   r   r   r   r   r   __contains__r   r  r   r  r  r   r   r   r.   r   rM   r  do_request_r   r   assertNotInunredirected_hdrs)r    rD   r  rc   r  r   rt   r1  r  hdrsnewreqs   &          r$   	test_httpHandlerTests.test_http  sG   NN..0!|#H#>LF#eU^4CCK''7 ?D		$$A FFAJJFFAHHFFAEESL$&668DHHd''QXXZ-TYY6TZZ+T[[&1T]]C0T--@A TYY-- ?2 $( &,,//D#F +I6)Q]]C8 ))D/6CS$B/A]]3'F|  !133H3HI  1F1FG  !6!67G!H#N  !6!6~!F@B S226:MJS226:FC ''(8%@''>''6''6]]3'FS223CDeLS22>BEJS226:EBS226:EB1 r'   c           	     b   \         P                  P                  4       p\        4       ;q!n        \
        P                  ! R RR7      pVP                  pVP                  4        V P                  \        P                  V4       \        VR4      ;_uu_ 4       p\        RV/ 4      pVP                  V4      pVP                  R4      pV P!                  VR4       V P#                  VP%                  R4      4       RRR4       \        VR4      ;_uu_ 4       p\        RVR	^/4      pVP                  V4      pV P!                  \'        VP                  R4      4      ^4       V P#                  VP%                  R4      4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)
zw+bF)modedeleterbrx   Transfer-encodingchunkedr  NContent-Length)r,   r   rE  r   r3  tempfileNamedTemporaryFiler7   r   r+   r1   unlinkr   r	   rG  rq   r   ro   rk   r8  )	r    rD   r  file_obj	file_pathr;   rt   rK  tes	   &        r$   test_http_body_file HandlerTests.test_http_body_file  sQ    NN..0!|#H..E%HMM			9-)T""a/B7C]]3'F""#67BR+V../?@A # )T""a/5Er4JKC]]3'FS!2!23C!DErJV../BCD	 #" #" #""s   A"F
A+F
F	F.	c                @   \         P                  P                  4       p\        4       ;q!n        \
        P                  ! 4       p\        R V/ 4      pVP                  V4      pV P                  VP                  R4      R4       V P                  VP                  R4      4       R^/p\        R W64      pVP                  V4      pV P                  \        VP                  R4      4      ^4       V P                  VP                  R4      4       VP                  4        R# )rx   rR  rS  r  rT  N)r,   r   rE  r   r3  r   BytesIOr	   rG  r   rq   ro   rk   r8  r   )r    rD   r  rX  rt   rK  rb   s   &      r$   test_http_body_fileobj#HandlerTests.test_http_body_fileobj  s     NN..0!|#H::<+Xr:s#**+>?K**+;<=#R(+X?s#V../?@A2F**+>?@r'   c           
     r   \         P                  P                  4       p\        4       ;q!n        \
        P                  R R.p/ R^/3 F  p\        P                  ! V\        P                  R7      ;_uu_ 4       p\        RVP                  V4      pVP                  V4      pV'       gD   V P                  VP                  R4      R4       V P                  VP                  R4      R4       M*V P                  \        VP                  R4      4      ^4       RRR4       K  	  R#   + '       g   i     K  ; i)	z-cpassrT  )stdoutrx   r  NrR  rS  )r,   r   rE  r   r3  sys
executable
subprocessPopenPIPEr	   rc  rG  r   rq   r8  )r    rD   r  cmdrb   procrt   rK  s   &       r$   test_http_body_pipe HandlerTests.test_http_body_pipe  s     NN..0!|#H~~tW-,b11G!!#joo>>$3T[['Js+$$V%6%67G%H$O$$V%6%67J%K%.0 $$S):):;K)L%M%') ?> 2>>>s   9BD%%D6c                   \         P                  P                  4       p\        4       ;q!n        R  p/ R^/3 F  p\        RV! 4       V4      pVP                  V4      pV'       gE   V P                  VP                  R4      R4       V P                  VP                  R4      R4       Kr  V P                  \        VP                  R4      4      ^4       K  	  R# )c               3      "   R x  R# 5i)s   oneNrS   rS   r'   r$   iterable_body;HandlerTests.test_http_body_iterable.<locals>.iterable_body  s
     Ls   	rT  rx   r  NrR  rS  )
r,   r   rE  r   r3  r	   rG  r   rq   r8  )r    rD   r  ro  rb   rt   rK  s   &      r$   test_http_body_iterable$HandlerTests.test_http_body_iterable  s     NN..0!|#H	 ,b11G/'JC]]3'F  !2!23C!DdK  !2!23F!G!*,   V%6%67G%H!I2N 2r'   c                   \         P                  P                  4       p\        4       Vn        VP                  \        R R4      4      pV P                  VP                  R4      R4       V P                  VP                  R4      4       R# )rx   rR  rS  r  NrS   )r,   r   rE  r   r3  rG  r	   r   rq   ro   rk   )r    rD   rt   s   &  r$   test_http_body_empty_seq%HandlerTests.test_http_body_empty_seq!  se    NN..0<mmG$92>?(;<iH(89:r'   c                <   \         P                  P                  4       p\        4       ;q!n        \
        P
                  ! R . RO4      p/ R^/3 FJ  p\        RW44      pVP                  V4      pV P                  \        VP                  R4      4      ^4       KL  	  R# )r  rT  rx   r  N)   r%        )r,   r   rE  r   r3  arrayr	   rG  r   r8  rq   )r    rD   r  iterable_arrayrb   rt   rK  s   &      r$   test_http_body_array!HandlerTests.test_http_body_array)  s     NN..0!|#HS3,b11G/IC]]3'FS!2!23C!DEbI 2r'   c                f   \         P                  P                  \        P                  P
                  R ^4      ;_uu_ 4        \        4       p\        4       pVP                  V4       VP                  R4       V P                  VP                  ^4       RRR4       R#   + '       g   i     R# ; i)r[  http://www.example.comN)r   patchr  r1  rv  HTTPConnectionr
   rX  rN  r   r   _debuglevelr    r  rD   s   &  r$   #test_http_handler_global_debuglevel0HandlerTests.test_http_handler_global_debuglevel6  sr    ZZt{{99<KK A!AMM!FF+,Q]]A. LKKK   ABB0	c                    \        4       p\        ^R7      pVP                  V4       VP                  R4       V P	                  VP
                  ^4       R# )   rZ  r  N)r
   rX  rN  r   r   r  r  s   &  r$   "test_http_handler_local_debuglevel/HandlerTests.test_http_handler_local_debuglevel>  sA    q)	a	'(*r'   r|  z)HTTPSConnection required for HTTPS tests.c                f   \         P                  P                  \        P                  P
                  R ^4      ;_uu_ 4        \        4       p\        4       pVP                  V4       VP                  R4       V P                  VP                  ^4       RRR4       R#   + '       g   i     R# ; i)r[  https://www.example.comN)r   r  r  r1  rv  r|  r
   r~  rN  r   r   r  r  s   &  r$   $test_https_handler_global_debuglevel1HandlerTests.test_https_handler_global_debuglevelE  sr    ZZt{{::L!LL A "AMM!FF,-Q]]A. MLLLr  c                    \        4       p\        ^R7      pVP                  V4       VP                  R4       V P	                  VP
                  ^4       R# )ry  rZ  r  N)r
   r~  rN  r   r   r  r  s   &  r$   #test_https_handler_local_debuglevel0HandlerTests.test_https_handler_local_debuglevelN  sA    *	a	()*r'   c                   \         P                  P                  4       p\        4       Vn        R p. ROpV F  p\        WB4      pVP                  V4      pV P                  VP                  R,          R4       VP                  RR4       VP                  V4      pV P                  VP                  R,          R4       K  	  R# )r'   r@  r   zsomeproxy:3128N)z#http://example.com/foo/bar/baz.htmlz$http://example.com//foo/bar/baz.htmlz$http://example.com/foo//bar/baz.htmlz$http://example.com/foo/bar//baz.html)
r,   r   rE  r   r3  r	   rG  r   rI  	set_proxy)r    rD   r   ds_urlsds_urlds_req	np_ds_reqp_ds_reqs   &       r$   test_http_doubleslash"HandlerTests.test_http_doubleslashV  s     NN..0< FV*F f-IY88@-P -t4}}V,HX77?O r'   c                r   . ROp\        R4      pV F  pW2n        \        V4      pV P                  VP	                  4       V4       T P                  VP
                  ;'       g    RVP
                  4       V P                  \        VP	                  4       4      P                  VP                  4       K  	  R# )http://example.com?foo=bar#bazr^   r   N)r  z)http://example.com?foo=bar&spam=eggs#bashr^   )r	   full_urlr   r   ry  fragmentquery)r    r3  r  rc   r2  s   &    r$   test_full_url_setter!HandlerTests.test_full_url_setterq  s    
 ()CJc]FQ^^-s3 QZZ--2v?Xann&67==v||L r'   c                    \        R 4      pV=V P                  VP                  4       V P                  VP                  4       V P	                  VP
                  R4       R# )r  r   N)r	   r  rp   r  r   r  )r    r  s   & r$   test_full_url_deleter"HandlerTests.test_full_url_deleter  sJ    ,-J!**%!**%R(r'   c                   \         P                  P                  4       p\        4       Vn        R p\        V4      pVP                  V4      pV P                  VP                  R4       V P                  VP                  R4       Rp\        V4      pVP                  V4      pV P                  VP                  R4       V P                  VP                  R4       R# )zhttp://www.python.org?getspamwww.python.orgz	/?getspamhttp://www.python.orgr   N)
r,   r   rE  r   r3  r	   rG  r   r  r  )r    rD   	weird_urlrt   rK  url_without_paths   &     r$   test_fixpath_in_weirdurls&HandlerTests.test_fixpath_in_weirdurls  s     NN..0<3	i s#&67+62&'s#&67"-r'   c                   \         P                  P                  4       p\        4       ;q!n        R p\        V4      p\        ^R/ RV4      pVP                  WE4      pV P                  WV4       V P                  VR4       \        ^R/ RV4      pVP                  WE4      pV P                  WV4       V P                  VR4       \        ^R/ RV4      pVP                  WE4      pV P                  WV4       V P                  VR4       \        RR/ RV4      pV P                  VP                  WE4      4       V P                  VP                  R4       V P                  VP                  WERR/ 34       R	# )
rx   r  r   r   AcceptedzPartial contenti  zBad gatewayr1  N)r,   r   HTTPErrorProcessorr   r3  r	   r   r  r.  assertNotHasAttrrp   r   r   r   )r    rD   r  rc   rt   r  newrs   &      r$   test_errorsHandlerTests.test_errors  s=   NN--/!|#H#cldBC0s&aa)j"b#6s&aa)/R=s&aa)mRS9!//#12&)##}b!ABr'   c                \   \        4       p\        P                  P                  V4      p\	        4       Vn        \        R 4      p\        ^R/ R4      pVP                  V4      pV P                  VP                  V4       V P                  VP                  V4       V P                  VP                  R4       V P                  VP                  4       VP                  W44      pV P                  VP                   V4       V P                  VP"                  V4       V P                  WF4       R# )rx   r  r   r   N)r   r,   r   HTTPCookieProcessorr   r3  r	   r   r  r.  r   r   origin_req_hostro   unverifiabler  r   r   )r    cjrD   rt   r  rK  r  s   &      r$   test_cookiesHandlerTests.test_cookies  s    _NN..r2<+,dB+$bjj#&bjj&),,m<))*s&bii%bggq!ar'   c                T   R pRp\         P                  P                  4       p\        4       ;qCn        R EF  pR EF  p\        VRV,          4      p\        W4      p\        P                  Vn	        VP                  RR4       Ve%   VP                  R\        \        V4      4      4       VP                  RR4        V! V\        4       VR	\        R
V/4      4       V P+                  VP,                  P/                  4       V4        V P+                  VP,                  P1                  4       R4       VP,                  P8                   U
u. uF  qP;                  4       NK  	  pp
V P=                  RV4       V P=                  RV4       V P+                  VP,                  P8                  R,          R4       V P=                  RVP,                  P8                  4       V P=                  RVP,                  P>                  4       EK  	  EK  	  \        V4      p\        P                  Vn	        V3R lp\        VRR7      p^ p\        P                  Vn	          V! W8R4       V^,           pK    \         P                   P"                   d?   p	T P%                  TR4       T P'                  T4       T	P)                  4         Rp	?	ELRp	?	ii ; i  \2         d*    T P5                  TP,                  P6                  4        ELi ; iu up
i   \         P                   P"                   dO   p	T P+                  T\         P                  P                  P@                  4       T	P)                  4         Rp	?	MRp	?	ii ; i\        TRR7      p^ p\        P                  Tn	          T! Y8RT,          4       T^,           pK    \         P                   P"                   dP   p	T P+                  T\         P                  P                  PB                  4       T	P)                  4         Rp	?	R# Rp	?	ii ; i)http://example.com/a.htmlhttp://example.com/b.htmlNzhttp_error_%sNonsensezviking=withholdrT  r<  r   BlahlocationrA  zcontent-lengthzcontent-typec           
      V    V P                  V\        4       R R\        RV/4      4       R# )r  r  r  N)r  r   r   )rD   rt   rc   s   &&&r$   r  ,HandlerTests.test_redirect.<locals>.redirect  s'    S(*c6(*c):;=r'   r   )r  rx   zhttp://example.com/%d)i-  r  i/  3  4  )Nz
blah
blah
)r  r  )"r,   r   HTTPRedirectHandlerr   r3  getattrr	   r   r   r   rm   rO   r&  rs   r   r   r   	HTTPErrorrN   assertIsNotNoner   r   rt   ry  
get_methodAttributeErrorro   r   rb   lowerrH  rI  max_repeatsmax_redirections)r    from_urlto_urlrD   r  r   r   r  rt   rP   xrb   r  r   s   &             r$   test_redirectHandlerTests.test_redirect  s;   .,NN..0!|#H ,D, Od$:;h-$<<z+<=#NN#3ST^D++FF; 3
D&&
F';<>   !3!3!5v>1$$QUU%5%5%7? /0eemm<m779m<  !17;  9  z!:!24  7  )@)@A? - ,F h44!' 	= h>44	!67	O ||--  MM$
3((.IIKK	  & 1$$QUUZZ01
 =6 ||%% 	UFNN$F$F$R$RSIIKK	 h>44	!85!@A	||%% 	U#^^??PPRIIKK	sb   ?I,	*KLL ,K	3KK	0L ?L M5'AM00M5N9 9P'AP""P'c                   R p. ROp. R	OpRp\         P                  P                  4       p\        4       ;qen        \        V4      p\        P                  Vn        V F  pVR,           V,           p	V P                  \         P                  P                  4      ;_uu_ 4       p
VP                  V\        4       RR\        RV	/4      4       RRR4       X
P                  P!                  4        K  	  V Fe  pVR,           V,           pVP                  V\        4       RR\        RV/4      4       V P#                  VP$                  P'                  4       V4       Kg  	  R#   + '       g   i     L; i)
r  zexample.com/b.htmlz://r  zSecurity Loopholer  NThat's fine)r1  httpsr  )fileimapldap)r,   r   r  r   r3  r	   r   r   r   r.   r   r  r  r   r   r  r   r   rt   ry  )r    r  valid_schemesinvalid_schemesschemeless_urlrD   r  rt   r  invalid_urlcm	valid_urls   &           r$   test_invalid_redirect"HandlerTests.test_invalid_redirect  s#   ..0-NN..0!|#Hh44%F 5.>9K""6<<#9#9::b  S*=[ 9:< ; LL  & $F7IS(*c=Z346QUU//19=	 $ ;:s   !)EE-c           
        R pRp\         P                  P                  4       p\        4       ;qCn        \        V4      p\        P                  Vn        \         P                  P                  W4      pVP                  V\        4       RR\        RV/4      4       V P                  VP                  P!                  4       V4       R# )r  z/b.htmlr  r  r  N)r,   r   r  r   r3  r	   r   r   r   r   urljoinr  r   r   r   rt   ry  )r    r  relative_urlrD   r  rt   r  s   &      r$   test_relative_redirect#HandlerTests.test_relative_redirect1  s    . NN..0!|#Hh44LL((?		hj#}Y/0	2++-y9r'   c                   ^ RI Hp ^ RIHp V! 4       pV! VRR4       \	        RR4      p\
        P                  P                  4       p\
        P                  P                  4       p\
        P                  P                  V4      p\        WEWg4      pVP                  R4       V P                  VP                  P                  R4      4       R# )	r   )	CookieJar)interact_netscapezhttp://www.example.com/z	spam=eggsr  z%Location: http://www.cracker.com/

CookieN)http.cookiejarr  test.test_http_cookiejarr  ri  r,   r   HTTPDefaultErrorHandlerr  r  rV  r   ro   rt   rk   )	r    r  r  r  hhhdehhrhcpr  s	   &        r$   test_cookie_redirect!HandlerTests.test_cookie_redirect>  s    ,>["7E$S*UV~~557nn002^^//3b0	()**845r'   c                >   R p\        RRV,           4      p\        P                  P                  4       p\        P                  P	                  4       p\        W#V4      pVP                  R4      pV P                  VP                  4       VP                  4       4       R# )z(http://www.example.com/index.html#OK

r  z
Location: r  N)
ri  r,   r   r  r  rV  r   r   r   strip)r    redirected_urlr  r  r  r  r   s   &      r$   test_redirect_fragment#HandlerTests.test_redirect_fragmentM  sv    G$S,*GH~~557nn002b,VV,-n&:&:&<=r'   c                  a aa S P                  \        P                  P                  4       \        P
                  P                  oR p\        P                  ! V4      \        P
                  n        S P                  \        \        P
                  RS4       \        R4      oVV V3R lpV\        P
                  P                  n        \        P                  P                  R4      pS P                  VP                  4       R4       R# )s(   HTTP/1.1 302 Found
Location: ?query

r  c                    < SP                  V\        S4      4       SP                  ! WV.VO5/ VB  R V P                  n        R# )s   HTTP/1.1 200 OK

Hello!N)r   nextr   r(  fakedata)connr  rc   poskw
real_classr    r3  s   &&&*,r$   r   3HandlerTests.test_redirect_no_path.<locals>.requesta  s=    S$t*-tS=3="=&FDNN#r'   zhttp://python.org/pathzhttp://python.org/path?queryN)z/pathz/path?query)r+   r,   r   r-   r1  rv  r  r   fakehttpr'  iterr0   r   r   )r    	response1r   r   r  r3  s   f   @@r$   test_redirect_no_path"HandlerTests.test_redirect_no_pathV  s     	112[[//
E	%0%9%9)%D".>
K,-	G
 .5""*^^##$<=&DEr'   c                    ! R  R\         P                  P                  4      pV! 4       p\         P                  P                  V4      pRpV F  w  rVV P	                  \        V4      4      ;_uu_ 4        \        P                  ! RV,           R,           4      Vn        VP                  R4      pRV,           R,           pVP                  p	V P                  W4       RRR4       K  	  R#   + '       g   i     K  ; i)	c                   &   a  ] tR tRt o R tRtV tR# )4HandlerTests.test_redirect_encoding.<locals>.Handlerim  c                    V P                  V P                  V4      pV P                  P                  V n        \        P
                  ! R 4      V n        V# )s)   HTTP/1.1 200 OK
Content-Length: 3

123)ra  
connectionbuflast_bufr   r   )r    rt   results   && r$   rc  >HandlerTests.test_redirect_encoding.<locals>.Handler.http_openn  sE    doos; $ 3 3"-"6"6# r'   )r	  r  N)rT   r   rU   rV   rc  rW   rX   rY   s   @r$   Handlerr  m  s     
 
r'   r  s!   HTTP/1.1 302 Redirect
Location: s   

rx   s   GET     N))s   /på-dansk/s   /p%C3%A5-dansk/)   /spaced%20path/r  )s   /spaced path/r  )s   /?på-dansks   /?p%C3%A5-dansk)r,   r   HTTPHandlerr  subTestreprr   r   r	  r   r  assertStartsWith)
r    r  r  rO  rF   r  r  r   r  r   s
   &         r$   test_redirect_encoding#HandlerTests.test_redirect_encodingj  s    	fnn00 	 ),,W5
 #(Xd8n--%0%9%9"$,-0&"
 ";;'<="V+d2!**%%g8 .- #(---s   5A(C++C<c                    R pRp\         P                  P                  4       p\        VRR7      p\	        4       pVP                  WERR/ V4      pV P                  VP                  4       R4       R# )r  r  HEADr  r  FoundN)r,   r   r  r	   r   r  r   r  )r    r  r  rD   rt   r   new_reqs   &      r$   test_redirect_head_request'HandlerTests.test_redirect_head_request  sb    .,NN..0hv.Z$$Sc7BG++-v6r'   c           	        R p\        VR7      \        VR7      3 F  p\        4       p\        P                  P	                  V4      pVP                  V4       R..p\        W54      p\        R4      pV P                  VP                  R4       VP                  V4       V P                  VP                  V4       T P                  V^ ,          R3.VP                   Uu. uF  qR,          NK  	  up4       K  	  R# u upi )	proxy.example.com:3128r1  )HTTPrc  zhttp://acme.example.com/zacme.example.comr   r%  NN)rc  r.  )dictr
   r,   r   ProxyHandlerrN  rS  r	   r   r  r   r4  )	r    ur~   r  phrP  rQ  rt   tups	   &        r$   
test_proxyHandlerTests.test_proxy  s    $1t|+A A,,Q/BMM"12I 1>H45CSXX'9:FF3KSXXq)x{K8923'':'3#hh':< , ;s   C=c                0   V P                  \        P                  ! 4       4      pR VR&   \        4       p\        P
                  P                  \        RR7      4      pVP                  V4       \        R4      pV P                  VP                  R4       VP                  V4       V P                  VP                  R4       \        R4      pV P                  VP                  R4       VP                  V4       V P                  VP                  R4       R# )	z
python.orgno_proxyproxy.example.comr   zhttp://www.perl.org/www.perl.orgr  r  NenterContextr   EnvironmentVarGuardr
   r,   r   r$  r#  rN  r	   r   r  r   r    envr  r&  rt   s   &    r$   test_proxy_no_proxy HandlerTests.test_proxy_no_proxy  s    	 = = ?@&J^^((3F)GH	b,->2	s#67-.#34	s#34r'   c                   V P                  \        P                  ! 4       4      pR VR&   \        4       p\        P
                  P                  \        RR7      4      pVP                  V4       \        R4      pV P                  VP                  R4       VP                  V4       V P                  VP                  R4       R# )*r+  r,  r   r  r  Nr.  r1  s   &    r$   test_proxy_no_proxy_all$HandlerTests.test_proxy_no_proxy_all  s    	 = = ?@J^^((3F)GH	b-.#34	s#34r'   c                   \        4       p\        P                  P                  \	        R R7      4      pVP                  V4       R..p\        W4      p\        R4      pV P                  VP                  R4       VP                  V4       V P                  VP                  R 4       T P                  V^ ,          R3.VP                   Uu. uF  qfR,          NK  	  up4       R# u upi )r  r  r  https://www.example.com/www.example.comr"  N)r  r.  )r
   r,   r   r$  r#  rN  rS  r	   r   r  r   r4  )r    r  r&  rP  rQ  rt   r'  s   &      r$   test_proxy_httpsHandlerTests.test_proxy_https  s    ^^((4L)MN	b./
	 -Q:01#45	s#;<8A;56./gg6gsc((g6	86s   C&
c                   \        4       p\        P                  P                  \	        R R7      4      pVP                  V4       \        4       pVP                  V4       \        R4      pVP                  RR4       VP                  RR4       V P                  VP                  R4       V P                  VP                  4       VP                  V4       V P                  R
VP                  P                   4       V P#                  RVP                  P                   4       V P%                  VP                  4       V P                  VP                  R 4       V P                  VP'                  R4      R4       R	# )r  r:  r;  Proxy-AuthorizationFooBar
User-AgentGrailr<  Proxy-authorizationN)r@  rA  )rB  rC  )r
   r,   r   r$  r#  rN  r~  r	   rm   r   r  rp   r	  r   rH  r]  r   rN   r  rq   )r    r  r&  https_handlerrt   s   &    r$   $test_proxy_https_proxy_authorization1HandlerTests.test_proxy_https_proxy_authorization  s#   ^^((4L)MN	b(*	m$01,h7|W-#45#**+	s 	:&//;;	=-#,,88	:S--.#;<(=>Ir'   r*   zonly relevant for Windowsc                   R p\         pR F"  pV P                  V! W14      RV,          4       K$  	  R	 F"  pV P                  V! W14      RV,          4       K$  	  RpV P                  V! RV4      RX,          4       V P                  V! RV4      RV,          4       R
 F"  pV P                  V! W14      RV,          4       K$  	  R# )z*www.example.com;*.example.net; 192.168.0.1z expected bypass of %s to be truer   example.net!expected bypass of %s to be Falsezexample.com; <local>z.expect <local> to bypass intranet address '%s'N)r<  zwww.example.netz192.168.0.1)r   zwww.example.orgrI  z192.168.0.2)testr  )r   rj   ro   )r    proxy_overrideproxy_bypassr  s   &   r$   test_winreg_proxy_bypass%HandlerTests.test_winreg_proxy_bypass  s    E4IDOOL>>EG J$D\$?@4GI$ 0]NC:TA	Cm^D<tC	E)DOOL>L"#$ *r'   darwinzonly relevant for OSXc                   R RR. RO/pR F%  pV P                  \        W!4      RV,          4       K'  	  R F%  pV P                  \        W!4      RV,          4       K'  	  R RR. /pV P                  \        RV4      4       R RRRR./pR	pV P                  \        W!4      RV,          4       R
pV P                  \        W!4      RV,          4       R# )exclude_simpleF
exceptionsz expected bypass of %s to be TruerJ  TrK  z10.0.0.0/40z172.19.10.0/24z172.19.10.5z10.0.1.5N)foo.barz	*.bar.com	127.0.0.1z10.10z10.0/16)rT  zwww.bar.comrU  z	10.10.0.1z10.0.0.1)zabc.foo.barzbar.comz	127.0.0.2z	10.11.0.1notinbypass)rj   r   ro   )r    bypassr  s   &  r$   test_osx_proxy_bypass"HandlerTests.test_osx_proxy_bypass  s     e &
!DOO8F>EG!
D9$G@4GI #D,;4VVDE eM+;=
 4TB:TA	C5dC;dB	Dr'   c                   V P                  W!R 7      ;_uu_ 4        \        4       p\        4       p\        P                  P                  V4      pRP                  V4      R,           p\        RV4      pVP                  V4       VP                  V4       V P                  W5RW'VRR4       RRR4       R#   + '       g   i     R# ; i))r  rb   z
rr    r  !http://acme.example.com/protectedN)
r  r
   r  r,   r   r   joinri  rN  _test_basic_auth)r    rb   r  rO  password_managerauth_handlerr  http_handlers   &&&     r$   check_basic_authHandlerTests.check_basic_auth$  s    \\\77#%F24!>>>>?OPL;;w'*4D23=L|,|,!!&"'7G"E"EG 8777s   BB55C	c           
        R pR pRV R2pRV R2pRpRV R2pRV R2RV R2RV R2V R	V 2V R	V 2V R	V 2V R	V 2V R	V 23 F  pR
V 2.pV P                  W4       K  	  \        P                  ! R\        34      ;_uu_ 4        RV 2.pV P                  W4       RRR4       W4.W6.Wc.3 F(  p	V	 U
u. uF  p
R
V
 2NK
  	  pp
V P                  W4       K*  	  R#   + '       g   i     LF; iu up
i )zrealm2@example.comzBasic realm=""zOtherscheme xxxzDigest realm="zn", qop="auth, auth-int", nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", opaque="5ccc069c403ebaf9f0171e9517f40e41"zBasic realm=''z", charset="UTF-8"z, zWWW-Authenticate: zBasic Auth Realm was unquotedzWWW-Authenticate: Basic realm=N)rb  r   check_warningsUserWarning)r    r  realm2basicbasic2other_no_realmdigest	realm_strrb   
challenges	challenges   &          r$   test_basic_authHandlerTests.test_basic_auth2  s   $%wa( **"6( +> ? E7!$E7!$ E7"45 gRx gR'(b(gRx hb 
I ,I;78G!!'1!
& ++-L%0-2 3 37w?@G!!'13 O
J )34(29 ,I;7(2  4!!'1
3 34s   
C 9C3 C0	c           
     z   \        4       p\        P                  P                  \	        R R7      4      pVP                  V4       \        4       p\        P                  P                  V4      pRp\        RRV,          4      pVP                  V4       VP                  V4       V P                  WRWVVRR 4       R# )r  r   ACME Networksi  z(Proxy-Authenticate: Basic realm="%s"

rD  z&http://acme.example.com:3128/protectedN)
r
   r,   r   r$  r#  rN  r  ProxyBasicAuthHandlerri  r^  )r    rO  r&  r_  r`  r  ra  s   &      r$   test_proxy_basic_auth"HandlerTests.test_proxy_basic_auth_  s    !^^((3K)LM2.0~~;;<LM.?%GI<(<(f4I#3CF6	 r'   c           
         ! R  R\         4      p ! R R\        P                  P                  4      p ! R R\        P                  P                  4      pV! 4       p\        4       pV! V4      pV! V4      pRp\        RRV,          4      p	VP                  V4       VP                  V4       VP                  V	4       V P                  WGR	WVR
R
4       V P                  VP                  RR.^,          4       R# )c                   ,   a  ] tR tRt o R tR tRtV tR# )QHandlerTests.test_basic_and_digest_auth_handlers.<locals>.RecordingOpenerDirectoriy  c                @    \         P                  ! V 4       . V n        R # r   )r
   r   recordedr   s   &r$   r   ZHandlerTests.test_basic_and_digest_auth_handlers.<locals>.RecordingOpenerDirector.__init__z  s    ''- "r'   c                <    V P                   P                  V4       R # r   )r|  r5  )r    r   s   &&r$   recordXHandlerTests.test_basic_and_digest_auth_handlers.<locals>.RecordingOpenerDirector.record~  s    $$T*r'   )r|  N)rT   r   rU   rV   r   r  rW   rX   rY   s   @r$   RecordingOpenerDirectorrz  y  s     #+ +r'   r  c                   &   a  ] tR tRt o R tRtV tR# )OHandlerTests.test_basic_and_digest_auth_handlers.<locals>.TestDigestAuthHandleri  c                    V P                   P                  R 4       \        P                  P                  P
                  ! V .VO5/ VB  R# )rm  N)r3  r  r,   r   HTTPDigestAuthHandlerhttp_error_401r    r   r:  s   &*,r$   r  ^HandlerTests.test_basic_and_digest_auth_handlers.<locals>.TestDigestAuthHandler.http_error_401  sA    ""8,44CCD L>BLFJLr'   rS   NrT   r   rU   rV   r  rW   rX   rY   s   @r$   TestDigestAuthHandlerr    s     L Lr'   r  c                   &   a  ] tR tRt o R tRtV tR# )NHandlerTests.test_basic_and_digest_auth_handlers.<locals>.TestBasicAuthHandleri  c                    V P                   P                  R 4       \        P                  P                  P
                  ! V .VO5/ VB  R# )rj  N)r3  r  r,   r   r   r  r  s   &*,r$   r  ]HandlerTests.test_basic_and_digest_auth_handlers.<locals>.TestBasicAuthHandler.http_error_401  sA    ""7+33BB4 K=AKEIKr'   rS   Nr  rY   s   @r$   TestBasicAuthHandlerr    s     K Kr'   r  rt  r[  &WWW-Authenticate: Basic realm="%s"

r  r\  rm  rj  N)r
   r,   r   r  r   r  ri  rN  r^  r   r|  )
r    r  r  r  rO  r_  digest_handlerbasic_handlerr  ra  s
   &         r$   #test_basic_and_digest_auth_handlers0HandlerTests.test_basic_and_digest_auth_handlersp  s    	+n 	+	LFNN$H$H 	L	K6>>#F#F 	K )*.0./?@,-=>.=EG=)>*<( 	f_#3CAA	  	8W*=a*?@r'   c                    \        4       p\        P                  P                  R 4      p\	        RR4      pVP                  V4       VP                  V4       V P                  \        VP                  R4       R # )Nr[  zWWW-Authenticate: Kerberos

r  )	r
   r,   r   r  ri  rN  r.   r/   r   )r    rO  digest_auth_handlerra  s   &   r$   $test_unsupported_auth_digest_handler1HandlerTests.test_unsupported_auth_digest_handler  sc    !$nnBB4H.57./<(*fkk3KLr'   c                    \        4       p\        P                  P                  R 4      p\	        RR4      pVP                  V4       VP                  V4       V P                  \        VP                  R4       R # )Nr[  zWWW-Authenticate: NTLM

r  )	r
   r,   r   r   ri  rN  r.   r/   r   )r    rO  basic_auth_handlerra  s   &   r$   #test_unsupported_auth_basic_handler0HandlerTests.test_unsupported_auth_basic_handler  sc    !#^^@@F.13-.<(*fkk3KLr'   c	                   ^ RI p	RRrVP                  WGW4       V P                  WFP                  4       V P                  WvP                  4       V P                  WP
                  4       V P                  WP                  4       VP                  V4       V P                  VP                  V4       V P                  VP                  V4       V P                  \        VP                  4      ^4       V P                  VP                  ^ ,          P                  V4      4       \        V
: RV: 2R4      pRV	P                  V4      P!                  4       P#                  4       ,           pV P                  VP                  ^,          P%                  V4      V4       V P                  VP                  ^,          P&                  V,          V4       R;Vn        Vn        VP)                  4        VP                  V4       V P                  \        VP                  4      ^4       V P                  VP                  ^ ,          P                  V4      4       R# )r   Nwilecoyote:asciizBasic )base64r   r   r  rc   r  rz   r   r  r  r&  ro  ro   rk   bytesencodebytesr  decoderq   rI  rk  )r    rO  r`  auth_headerr  ra  r_  request_urlprotected_urlr  r  rz   userpassauth_hdr_values   &&&&&&&&&     r$   r^  HandlerTests._test_basic_auth  s    	h 	!!%dE 6 67&:&:;445#<#<=K  	)66>)44mD 	\223Q7..q1<<[IJD(3W="x(..0779:..q1<<[I'	)..q1CCKP'	) =A@ 0 9K \223Q7..q1<<[IJr'   c                   R Rr!Rp\        ^4      p\        4       p\        V4      pVP                  RW1VRR7       V P	                  VP                  V4      4       V P	                  VP                  VR,           4      4       V P                  VP                  VR,           4      4       \        4       pVP                  V4       VP                  V4       VP                  V4       V P	                  VP                  4       R# )r  r  r\  NT)is_authenticatedz/nestedplain)r  r   r   r   rj   r  ro   r
   rN  r   r  )r    r  rz   r  ra  pwd_managerauth_prior_handlerrO  s   &       r$   test_basic_prior_auth_auto_send,HandlerTests.test_basic_prior_auth_auto_send  s      h9/4241+>''+X 	( 	F 	44[AB44[95LMN55kG6KLM!-.<(K  	445r'   c                   R Rr!RpRp\        4       p\        V4      pVP                  WCW4       VP                  V4      pV P	                  V4       \        4       pVP                  V4       \        RRR,          4      p	VP                  V	4       VP                  V4       VP                  V4      pV P                  V4       \        ^4      p	V P	                  V	P                  4       \        4       pVP                  V4       VP                  V	4       VP                  V4       V P                  V	P                  4       R# )r  r  r\  ACMEr[  r  N)r   r   r   r  ro   r
   rN  ri  r   rj   r  r  )
r    r  rz   r  r  r  r  is_authrO  ra  s
   &         r$   .test_basic_prior_auth_send_after_first_success;HandlerTests.test_basic_prior_auth_send_after_first_success  s     h9241+>''DK..{;!!-..=DF<(K ..{; /4556!-.<( 	K  	445r'   c                   R F  w  rRP                  V4      p\        P                  ! VP                  4       V,           4      p\        P
                  P                  4       p\        R4      pRVn        VP                  WF4      ;_uu_ 4       pVP                  4        RRR4       V P                  VP                  P                  RP                  V4      4       K  	  R#   + '       g   i     LK; i)z=Test the connection is cleaned up when the response is closedzHTTP/1.1 200 OK
{}

http://dummy/NzConnection not closed with {!r}))zConnection: close   data)zTransfer-Encoding: chunkeds   4
data
0

)zContent-Length: 4r  )formatr   r   encoder,   r   rE  r	   r   ra  r8   rj   fakesockclosed)r    transferr   headerr  r  rt   resps   &       r$   test_http_closedHandlerTests.test_http_closed  s    !
X
 5;;HEF''$(>?Dnn88:G/*CCK++t		 ,OODMM00188BD!
 ,+s   C!!C1c                   \         P                  ! R4      p\        P                  P	                  4       p\        R4      pRVn        V P                  \        P                  P                  4      ;_uu_ 4        VP                  W4       RRR4       V P                  VP                  P                  R4       R#   + '       g   i     L8; i)z;Test the connection is cleaned up after an invalid responser'   r  NzConnection not closed)r   r   r,   r   rE  r	   r   r.   r1  rv  BadStatusLinera  rj   r  r  )r    r  r  rt   s   &   r$   test_invalid_closed HandlerTests.test_invalid_closed/  s    ##C(..446o&t{{8899OOD& :,,.EF :9s   8B::C
	rS   N)@rT   r   rU   rV   r  r   requires_resourcer  r8  rL  r[  r_  r   rk  rq  rt  r|  r  r  r!  
skipUnlessrD  r1  rv  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r(  r3  r7  r=  rF  r1   r7   rN  rd  platformrX  rb  rq  rv  r  r  r  r^  r  r  r  r  rW   rX   rY   s   @r$   r  r    s    >@ y)8 *8*]5~@CDE2. ) ),O(;J/+ .?@Bmn/ o/ .?@Bmn+ o+P6M.).&C2"KZ>0:6>F(!9F7<$5	58  .?@BmnJ oJ. D*EF$ G$. 13JKD LDBG+2Z "0AdMM#KJ66&6PD"G Gr'   r  c                   >   a  ] tR tRt o R tR tR tR tR tRt	V t
R# )		MiscTestsi:  c                   a T P                  \        ;QJ d5    V3R  lVP                   4       F  '       g   K   R4       R# 	  R4       R# ! V3R  lVP                   4       4      4       R# )c              3   B   <"   T F  pVP                   S8H  x  K  	  R # 5ir   )r(  ).0rD   handler_classs   & r$   	<genexpr>/MiscTests.opener_has_handler.<locals>.<genexpr>=  s!      6%4 KK=8%4s   TFN)rj   anyrQ  )r    rO  r  s   &&fr$   opener_has_handlerMiscTests.opener_has_handler<  sL     6%+__6 	7 	7 6%+__6 6 	7r'   c                    ! R  R\         P                  P                  4      p ! R R\         P                  P                  4      p ! R R\         P                  P                  4      p\         P                  P                  pV! W#4      pV P                  WR4       V P                  WS4       V! W#! 4       4      pV P                  WR4       V P                  WS4       V! V4      pV P                  WQ4       V! 4       pV P                  V\         P                  P                  4       V! \         P                  P                  4      pV P                  V\         P                  P                  4       V! \         P                  P                  4       4      pV P                  V\         P                  P                  4        ! R R\         P                  P                  4      pV! W4      pV P                  WQ4       V P                  WV4       R# )	c                       ] tR tRtRtR# )2MiscTests.test_build_opener.<locals>.MyHTTPHandleriA  rS   NrK  rS   r'   r$   MyHTTPHandlerr  A  rM  r'   r  c                   &   a  ] tR tRt o R tRtV tR# )/MiscTests.test_build_opener.<locals>.FooHandleriD  c                    R # r   rS   r   s   &r$   foo_open8MiscTests.test_build_opener.<locals>.FooHandler.foo_openE  r  r'   rS   N)rT   r   rU   rV   r  rW   rX   rY   s   @r$   
FooHandlerr  D        r'   r  c                   &   a  ] tR tRt o R tRtV tR# )/MiscTests.test_build_opener.<locals>.BarHandleriH  c                    R # r   rS   r   s   &r$   bar_open8MiscTests.test_build_opener.<locals>.BarHandler.bar_openI  r  r'   rS   N)rT   r   rU   rV   r  rW   rX   rY   s   @r$   
BarHandlerr  H  r  r'   r  c                       ] tR tRtRtR# )7MiscTests.test_build_opener.<locals>.MyOtherHTTPHandlerie  rS   NrK  rS   r'   r$   MyOtherHTTPHandlerr  e  rM  r'   r  N)r,   r   r  BaseHandlerr  r  )r    r  r  r  r  r  r  s   &      r$   test_build_openerMiscTests.test_build_opener@  s   	FNN66 		33 		33 	 ~~220.. Z\2.. '1 N6>>#=#=>3346>>#=#=>33566>>#=#=>	!;!; 	 ;16r'   c                   RpR;p;r4Rp\         P                  P                  W#WV4      pV P                  VR4       V P	                  VP
                  R4       V P                  VR4       V P	                  VP                  R4       RVP                  : RVP                  : 2pV P	                  \        V4      V4       RVP                  : RVP                  : R	2pV P	                  \        V4      V4       VP                  4        R# )
z}
Issue 13211 reveals that HTTPError didn't implement the URLError
interface even though HTTPError is a subclass of URLError.
zsomething bad happenedNzContent-Length: 42rL   rb   zHTTP Error z: z<HTTPError >)r,   r   r  assertHasAttrr   rL   rb   r   r   rO   r  r   )r    r   rc   r   r   rJ  rP   expected_errmsgs   &       r$   test_HTTPError_interface"MiscTests.test_HTTPError_interfacel  s    
 'd#ll$$S2>3)%=>3	*&:;14377CS?325((CGGDcO4		r'   c                   \         P                  P                  R RRRR4      pV P                  \	        VRR4      R4       V P                  VP                  P                  4       \        4       VP                  4        R# )rc   i  zMETHOD NOT ALLOWEDN	__notes__rS   )
r,   r   r  r   r  r  r   r8   r  r   )r    r  s   & r$   test_gh_98778MiscTests.test_gh_98778  s[    LL""5#/CT4PK4b9addiik51		r'   c                    . ROpV F   w  r#V P                  \        V4      V4       K"  	  V P                  \        \        R4      3 R# )r,  Nzfile:/ftp.example.com)r,  )NNNr,  r  )NNNr  r  r  )zjoe:password@proxy.example.com)Nry   rz   r,  )z#joe:password@proxy.example.com:3128)Nry   rz   r  )zhttp://proxy.example.com/)r1  NNr,  )zhttp://proxy.example.com:3128/)r1  NNr  )z&http://joe:password@proxy.example.com/r1  ry   rz   r,  )z*http://joe:password@proxy.example.com:3128)r1  ry   rz   r  )z1ftp://joe:password@proxy.example.com/rubbish:3128)r  ry   rz   r,  )z%http://joe:password@proxy.example.comr  )z&http://user/name:password@localhost:22)r1  	user/namerz   localhost:22)z&http://username:pass/word@localhost:22)r1  username	pass/wordr  )z'http://user/name:pass/word@localhost:22)r1  r  r  r  )r   r   r.   r/   )r    parse_proxy_test_casestcr  s   &   r$   test_parse_proxyMiscTests.test_parse_proxy  sF    $"
N 3LB\"-x8 3 	*l4KLMr'   rS   N)rT   r   rU   rV   r  r  r  r  r  rW   rX   rY   s   @r$   r  r  :  s&     7*7X&+N +Nr'   r  zEconservative skip due to OpenSSL FIPS mode possible algorithm nerfingc                   \   a  ] tR tRt o R t]R 4       t]R 4       t]R 4       tR t	Rt
V tR# )	TestDigestAuthAlgorithmsi  c                $    \        4       V n        R # r   )r   r  r   s   &r$   setUpTestDigestAuthAlgorithms.setUp  s    02r'   c                    V P                   P                  R 4      w  rV P                  V! R4      R4       V P                  V! RR4      R4       R# )MD5r    acbd18db4cc2f85cedef654fccc4a4d8r    4e99e8c12de7e01535248d2bac85e732Nr  get_algorithm_implsr   r    HKDs   &  r$   test_md5_algorithm+TestDigestAuthAlgorithms.test_md5_algorithm  sE    0075#EFE5)+MNr'   c                    V P                   P                  R 4      w  rV P                  V! R4      R4       V P                  V! RR4      R4       R# )SHAr   (0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33r   (54dcbe67d21d5eb39493d46d89ae1f412d3bd6deNr  r  s   &  r$   test_sha_algorithm+TestDigestAuthAlgorithms.test_sha_algorithm  sE    0075#MNE5)+UVr'   c                    V P                   P                  R 4      w  rV P                  V! R4      R4       V P                  V! RR4      R4       R# )zSHA-256r   @2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7aer   @a765a8beaa9d561d4c5cbed29d8f4e30870297fdfa9cb7d6e9848a95fec9f937Nr  r  s   &  r$   test_sha256_algorithm.TestDigestAuthAlgorithms.test_sha256_algorithm  sE    00;5#efE5)+mnr'   c                    V P                  \        4      ;_uu_ 4       pV P                  P                  R 4       RRR4       V P	                  \        XP                  4      R4       R#   + '       g   i     L7; i)invalidNz5Unsupported digest authentication algorithm 'invalid')r.   r/   r  r  r   rO   r  )r    excs   & r$   test_invalid_algorithm/TestDigestAuthAlgorithms.test_invalid_algorithm  sR    z**cLL,,Y7 +C	
 +*s   A))A9	)r  N)rT   r   rU   rV   r  skip_libssl_fips_moder  r  r  r!  rW   rX   rY   s   @r$   r  r    sV     3 O O
 W W
 o o

 
r'   r  c                      a  ] tR tRt o  ! R R]4      tR tR tR tR t	R t
R	 tR
 tR tR tR tR tR tR tR tRtV tR# )RequestTestsi  c                       ] tR tRtRtRtR# )RequestTests.PutRequesti  PUTrS   N)rT   r   rU   rV   r  rW   rS   r'   r$   
PutRequestr'    s    r'   r)  c                    \        R 4      V n        \        R RRR/R7      V n        \        R RR7      V n        V P	                  R 4      V n        V P	                  R RR7      V n        R# )	http://www.python.org/~jeremy/r   zX-TestrK  ra   r  r  rB  N)r	   r   postheadr)  put
force_postr   s   &r$   r  RequestTests.setUp  sf    ;<<"%-v$68	 <VL	??#CD//*J * r'   c                   V P                  R V P                  P                  4       4       V P                  RV P                  P                  4       4       V P                  RV P                  P                  4       4       V P                  RV P
                  P                  4       4       V P                  R V P                  P                  4       4       R# )rB  rA  r  r(  N)r   r,  r  r   r-  r.  r/  r   s   &r$   test_methodRequestTests.test_method  s    !5!5!78 3 3 56!5!5!78 3 3 56!;!;!=>r'   c                d   V P                  V P                  P                  4       V P                  R V P                  P	                  4       4       RV P                  n        V P                  V P                  P                  4       V P                  RV P                  P	                  4       4       R# )rA  r   rB  N)ro   r   r   r   r  rj   r   s   &r$   	test_dataRequestTests.test_data  sq    ' 3 3 56&!4!4!67r'   c                R   V P                  R V P                  P                  4       V P                  P                  R ^*4       V P	                  ^*V P                  P                  R ,          4       RV P                  n        V P                  R V P                  P                  4       R# )r  r   N)rH  r   rI  rs   r   r   r   s   &r$   .test_setting_data_should_remove_content_length;RequestTests.test_setting_data_should_remove_content_length  sx    )488+E+EF(()92>TXX778HIJ)488+E+EFr'   c                j   V P                  R V P                  P                  4       RV P                  n        V P                  P	                  R ^4       V P                  ^V P                  P                  R ,          4       V P                  =V P                  R V P                  P                  4       R# )r  r   N)rH  r   rI  r   rs   r   r   s   &r$   /test_deleting_data_should_remove_content_length<RequestTests.test_deleting_data_should_remove_content_length  s    )488+E+EF(()91=DHH667GHIHHM)488+E+EFr'   c                Z    V P                  R V P                  P                  4       4       R# )r+  N)r   r   ry  r   s   &r$   test_get_full_urlRequestTests.test_get_full_url  s#    9..0	2r'   c                    V P                  R V P                  P                  4       \        R4      pV P                  RVP                  4       R# )z	/~jeremy/zhttp://www.python.org/r)   N)r   r   r  r	   rb  s   & r$   test_selectorRequestTests.test_selector  s;    dhh&7&78./cll+r'   c                R    V P                  R V P                  P                  4       R# )r1  N)r   r   r/  r   s   &r$   test_get_typeRequestTests.test_get_type  s    /r'   c                R    V P                  R V P                  P                  4       R# )r  N)r   r   r  r   s   &r$   test_get_hostRequestTests.test_get_host  s    )488==9r'   c                T    \        R 4      pV P                  RVP                  4       R# )zhttp://www.%70ython.org/r  Nr	   r   r  rb  s   & r$   test_get_host_unquote"RequestTests.test_get_host_unquote  s"    01)3884r'   c                z   V P                  V P                  P                  4       4       V P                  P                  R R4       V P	                  V P                  P                  4       4       V P                  RV P                  P                  4       V P                  R V P                  P                  4       R# )r-  r1  r  N)ro   r   	has_proxyr  rj   r   r  r  r   s   &r$   r(  RequestTests.test_proxy  s}    ++-.>62**,-)488+C+CD7r'   c                T    \        R 4      pV P                  RVP                  4       R# )z<URL:http://www.python.org>r  NrJ  rb  s   & r$   test_wrapped_urlRequestTests.test_wrapped_url!  s"    34)3884r'   c                    \        R 4      pV P                  RVP                  4       \        R4      pV P                  RVP                  4       Rp\        V4      pV P                  VP                  4       V4       R# )-http://www.python.org/?qs=query#fragment=truez
/?qs=queryzhttp://www.python.org/#fun=truer)   .http://docs.python.org/library/urllib2.html#OKN)r	   r   r  ry  )r    rt   rc   s   &  r$   test_url_fragmentRequestTests.test_url_fragment%  si    EFs||478cll+ ?cl))+S1r'   c                    . ROpV F8  p\        V4      pV P                  VP                  4       VP                  4       K:  	  R# )http://docs.python.orgN)rY  rU  rT  )r	   r   ry  r  )r    r3  rc   rt   s   &   r$   test_url_fullurl_get_full_url*RequestTests.test_url_fullurl_get_full_url0  s<    A C#,CS--/> r'   )r/  r   r-  r,  r.  N)rT   r   rU   rV   r	   r)  r  r2  r5  r8  r;  r>  rA  rD  rG  rK  r(  rQ  rV  rZ  rW   rX   rY   s   @r$   r%  r%    s^     W ?8GG2,
0:585	2? ?r'   r%  __main__)Gr!  rK  r   test.supportr   r   r   r   r   r1   r   r  r   rz  rd  rU  rf  urllib.requestr,   r	   r
   r   r   r   r   r   r   urllib.parser   r  http.clientr1  requires_working_socketTestCaser   r\   r   r   r#  r   r   r   r   r   IOBaser   r   r  rS  rV  r   r  rX  r  ri  rD  rv  HTTPSHandlerr~  r  r  r  r  r  skipIfis_libssl_fips_moder#  r  r%  rT   mainrS   r'   r$   <module>rh     s     " , (   	 	    
   7 7 7
 "     t ,-,8$$ -,`x'x(( x'v, , #$ #
	2;; 	3 3? ?ryy $* *Z38 38lD0fnn00 0Hfnn88 H8 4;;)**	46>>66 	4Qv~~99 Q&
( 
(NA(++ NAbjG8$$ jGZ#vN!! vNr !!K 
x00 
>^?8$$ ^?B zMMO r'   