+
    Bi`                     P   ^ 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 ^ RIHt ^ RIHt  ^ RIt]P$                  ! RR7       ]P&                  P)                  ]4      t]P&                  P/                  ]RR4      t]P&                  P/                  ]RR	4      t ! R
 R]P4                  P6                  4      t ! R R]P:                  4      t ! R R4      t ! R R]P4                  P@                  4      t! ! R R]P4                  P@                  4      t" ! R R]	PF                  4      t$]PJ                  ! RRR7       ! R R]	PF                  4      4       t&R t' ! R R]	PF                  4      t(R t)]*R8X  d   ]	PV                  ! 4        R# R#   ] d    Rt ELhi ; i)    N)support)hashlib_helper)threading_helperT)modulecertdatazkeycert.pemzkeycert2.pemc                   ,   a  ] tR t^t o R tR tRtV tR# )LoopbackHttpServerc                    \         P                  P                  P                  V VV4       V P                  P                  R 4       R# )g?N)httpserver
HTTPServer__init__socket
settimeout)selfserver_addressRequestHandlerClasss   &&&1/usr/lib/python3.14/test/test_urllib2_localnet.pyr   LoopbackHttpServer.__init__$   s6    ''(6(;	= 	s#    c                b    V P                   P                  4       w  rVP                  R 4       W3# )g      $@)r   acceptr   )r   requestclient_addresss   &  r   get_requestLoopbackHttpServer.get_request-   s2     #'++"4"4"6
 	4 ((r    N)__name__
__module____qualname____firstlineno__r   r   __static_attributes____classdictcell____classdict__s   @r   r	   r	      s     
$
) 
)r   r	   c                   2   a  ] tR t^9t o R tR tR tRtV tR# )LoopbackHttpServerThreadc                    \         P                  P                  V 4       R V n        \         P                  ! 4       V n        RVn        \        RV4      V n        V P                  P                  V n
        R# )FzHTTP/1.0N)z	127.0.0.1r   )	threadingThreadr   _stop_serverEventreadyprotocol_versionr	   httpdserver_portportr   request_handlers   &&r   r   !LoopbackHttpServerThread.__init__<   sW    !!$'!__&
+5('(8(79
JJ**	r   c                h    R V n         V P                  4        V P                  P                  4        R# )TN)r+   joinr/   server_closer   s   &r   stopLoopbackHttpServerThread.stopE   s%     !		

!r   c                    V P                   P                  4        V P                  '       g   V P                  P	                  4        K.  R # N)r-   setr+   r/   handle_requestr8   s   &r   runLoopbackHttpServerThread.runM   s1    

###JJ%%' $r   )r+   r/   r1   r-   N)	r   r   r    r!   r   r9   r?   r"   r#   r$   s   @r   r'   r'   9   s     +"( (r   r'   c                   V   a  ] tR t^Tt o R tR tR tR tR tR t	R t
R tR	 tR
tV tR# )DigestAuthHandlerc                L    ^ V n         . V n        / V n        RV n        RV n        R# )r   z
Test RealmauthN)_request_num_nonces_users_realm_name_qopr8   s   &r   r   DigestAuthHandler.__init__W   s'    '	r   c                    Wn         R # r<   )rI   )r   qops   &&r   set_qopDigestAuthHandler.set_qop^   s    	r   c                    Wn         R # r<   )rG   )r   userss   &&r   	set_usersDigestAuthHandler.set_usersa   s    r   c                    Wn         R # r<   )rH   )r   realms   &&r   	set_realmDigestAuthHandler.set_realme   s     r   c                    V ;P                   ^,          un         \        P                  ! \        V P                   4      P	                  R4      4      P                  4       pV P                  P                  V4       V# )   ascii)rE   hashlibmd5strencode	hexdigestrF   append)r   nonces   & r   _generate_nonce!DigestAuthHandler._generate_nonceh   sW    QC 1 1299'BCMMOE"r   c                (   VP                  R 4      pW^,           R pVP                  R4      p/ pV F\  pVP                  R4      w  rgVP                  4       pV^ ,          R8X  d   VR,          R8X  d   V^R pMVP                  4       pWtV&   K^  	  V# ) N,=")findsplitstrip)r   auth_strfirst_space_indexparts	auth_dictpartnamevalues   &&      r   _create_auth_dict#DigestAuthHandler._create_auth_dictn   s    $MM#.a/01s#	D**S/KD::<DQx359#3a#dO  r   c                   / pVP                  V4       W%R &   W5R&   WER&   RV,          p\        P                  ! VP                  R4      4      P	                  4       pRV,          p\        P                  ! VP                  R4      4      P	                  4       p	WuR&   WR&   RV,          p
\        P                  ! V
P                  R4      4      P	                  4       pWR	,          8H  # )
passwordmethoduriz#%(username)s:%(realm)s:%(password)srY   z%(method)s:%(uri)sHA1HA2z3%(HA1)s:%(nonce)s:%(nc)s:%(cnonce)s:%(qop)s:%(HA2)sresponse)updaterZ   r[   r]   r^   )r   ro   rv   rw   rx   
final_dictHA1_strry   HA2_strrz   response_strr{   s   &&&&&       r   _validate_auth DigestAuthHandler._validate_auth   s    
)$!):%857*Dkk'..12<<>&3kk'..12<<>5546@A;;|227;<FFHZ000r   c           
     &   VP                  R R4       VP                  RR4       VP                  RRV P                  : RV P                  : RV P	                  4       : R24       VP                  4        VP                  P                  R	4       R
# )i  zProxy Authentication RequiredContent-Type	text/htmlzProxy-AuthenticatezDigest realm="z", qop="z	",nonce="z", s   Proxy Authentication Required.F)send_responsesend_headerrH   rI   ra   end_headerswfilewriter2   s   &&r   _return_auth_challenge(DigestAuthHandler._return_auth_challenge   s}    %%c+JK##NK@##  tyy$*>*>*@#B	C 	##%##$EFr   c                   \        V P                  4      ^ 8X  d   R# RVP                  9  d   V P                  V4      # V P	                  VP                  R,          4      pVR,          V P                  9   d   V P                  VR,          ,          pMV P                  V4      # VP                  R4      V P                  9   g   V P                  V4      # V P                  P                  VR,          4       RpVP                  VP                  3 F+  pV P                  VVVP                  V4      '       g   K)  RpK-  	  V'       g   V P                  V4      # R# )r   TzProxy-Authorizationusernamer`   F)lenrG   headersr   rs   getrF   removepath
short_pathr   command)r   r3   ro   rv   auth_validatedr   s   &&    r   r>    DigestAuthHandler.handle_request   s1    t{{q  (?(??..??..''(=>I $3;;	*(=?22?CC==)T\\922?CC##Ig$67"N )--/I/IJ&&y'/'6'>'>'+- - &*N K "22?CCr   )rF   rI   rH   rE   rG   N)r   r   r    r!   r   rM   rQ   rU   ra   rs   r   r   r>   r"   r#   r$   s   @r   rB   rB   T   s7     !"1$* *r   rB   c                      a  ] tR t^t o RtRtRt]: R]: 2t]P                  ! ]P                  R4      4      P                  R4      tR tR tR tR	 tR
 tRtV tR# )BasicAuthHandlertestUsertestPassTest:rY   c                b    \         P                  P                  P                  ! V .VO5/ VB  R # r<   )r   r   BaseHTTPRequestHandlerr   )r   argskwargss   &*,r   r   BasicAuthHandler.__init__   s$    **33DJ4J6Jr   c                    R # r<   r   r   formatr   s   &&*r   log_messageBasicAuthHandler.log_message   s    r   c                l    V P                  ^4       V P                  RR4       V P                  4        R# )   Content-typer   N)r   r   r   r8   s   &r   do_HEADBasicAuthHandler.do_HEAD   s,    35r   c                    V P                  R 4       V P                  RRV P                  ,          4       V P                  RR4       V P                  4        R# )i  zWWW-AuthenticatezBasic realm="%s"r   r   N)r   r   REALMr   r8   s   &r   do_AUTHHEADBasicAuthHandler.do_AUTHHEAD   sG    3+-ADJJ-NO5r   c                   V P                   P                  R R4      '       g.   V P                  4        V P                  P	                  R4       R# V P                   P                  R R4      RV P
                  ,           8X  d?   V P                  ^4       V P                  4        V P                  P	                  R4       R# V P                  4        R# )Authorization s   No Auth header receivedzBasic s   It worksN)r   r   r   r   r   ENCODED_AUTHr   r   r8   s   &r   do_GETBasicAuthHandler.do_GET   s    ||44JJ78\\%(043D3D(DEs#JJ[) r   r   N)r   r   r    r!   USERPASSWDr   USER_PASSWDbase64	b64encoder]   decoder   r   r   r   r   r   r"   r#   r$   s   @r   r   r      se      DFE!6*K##K$6$6w$?@GGPLK
 r   r   c                   2   a  ] tR t^t o R tR tR tRtV tR# )FakeProxyHandlerc                n    Wn         \        P                  P                  P                  ! V .VO5/ VB  R # r<   )digest_auth_handlerr   r   r   r   )r   r   r   r   s   &&*,r   r   FakeProxyHandler.__init__   s,     $7 **33DJ4J6Jr   c                    R # r<   r   r   s   &&*r   r   FakeProxyHandler.log_message  s     	r   c                   \         P                  P                  V P                  R 4      w  rr4rVW0n        V P
                  P                  V 4      '       d   V P                  ^R4       V P                  RR4       V P                  4        V P                  P                  \        RV P                  ,          R4      4       V P                  P                  R4       R# R# )r   OKr   r   zYou've reached %s!<BR>rY   sF   Our apologies, but our server is down due to a sudden zombie invasion.N)urllibparseurlparser   r   r   r>   r   r   r   r   r   bytes)r   scmnetlocr   paramsqueryfragments   &      r   r   FakeProxyHandler.do_GET  s    7=||7L7LIIv84dE##22488sD)^[9JJU#;dii#G#*, -JJ : ; 9r   )r   r   N)	r   r   r    r!   r   r   r   r"   r#   r$   s   @r   r   r      s     K
; ;r   r   c                   `   a a ] tR tRt oRtRtRtRtV 3R ltR t	V 3R lt
R	 tR
 tRtVtV ;t# )BasicAuthTestsi  r   r   	Incorrectr   c                H  < \         \        V `  4        R  p\        V4      V n        V P                  V P                  4       RV P                  P                  ,          V n        V P                  P                  4        V P                  P                  P                  4        R# )c                      \        V / VB # r<   )r   )r   r   s   *,r   #http_server_with_basic_auth_handlerABasicAuthTests.setUp.<locals>.http_server_with_basic_auth_handler#  s    #T4V44r   zhttp://127.0.0.1:%sN)superr   setUpr'   r   
addCleanupstop_serverr1   
server_urlstartr-   wait)r   r   	__class__s   & r   r   BasicAuthTests.setUp   sp    nd)+	5./RS(()/$++2B2BB r   c                H    V P                   P                  4        R V n         R # r<   r   r9   r8   s   &r   r   BasicAuthTests.stop_server+      r   c                ,   < \         \        V `  4        R # r<   )r   r   tearDown)r   r   s   &r   r   BasicAuthTests.tearDown/  s    nd,.r   c                4   \         P                  P                  4       pVP                  V P                  V P
                  V P                  V P                  4       \         P                  P                  \         P                  P                  V4      4        V P                  \         P                  P                  V P
                  4      4       R#   \         P                  P                   d'    T P                  R T P
                  ,          4        R# i ; i)z!Basic auth failed for the url: %sN)r   r   HTTPBasicAuthHandleradd_passwordr   r   r   r   install_openerbuild_opener
assertTrueurlopenerror	HTTPErrorfail)r   ahs   & r   test_basic_auth_success&BasicAuthTests.test_basic_auth_success2  s    ^^002


DOOTYYL%%fnn&A&A"&EF	MOOFNN224??CD||%% 	MII9DOOKL	Ms   8C ADDc                R   \         P                  P                  4       pVP                  V P                  V P
                  V P                  V P                  4       \         P                  P                  \         P                  P                  V4      4       V P                  \         P                  P                  4      ;_uu_ 4       p\         P                  P                  V P
                  4       R R R 4       XP                  P                  4        R #   + '       g   i     L,; ir<   )r   r   r   r   r   r   r   INCORRECT_PASSWDr   r   assertRaisesr   r   r   	exceptionclose)r   r   cms   &  r   test_basic_auth_httperror(BasicAuthTests.test_basic_auth_httperror;  s    ^^002


DOOTYY@U@UV%%fnn&A&A"&EFv||5566"NN""4??3 7
 76s   *DD&	)r   r   )r   r   r    r!   r   r   r   r   r   r   r   r   r   r"   r#   __classcell__r   r%   s   @@r   r   r     s9     DF"E	!/M r   r   r[   )opensslc                   `   a a ] tR tRt oRtRtRtRtV 3R ltR t	R t
R	 tR
 tR tRtVtV ;t# )ProxyAuthTestsiD  zhttp://localhosttestertest123	TestRealmc                  <a  \         \        S `  4        R  pS P                  V\        P
                  P                  4       4       R\        P
                  R&   R\        P
                  R&   \        4       S n        S P                  P                  S P                  S P                  /4       S P                  P                  S P                  4       V 3R lp\        V4      S n        S P                  S P                   4       S P                  P#                  4        S P                  P$                  P'                  4        RS P                  P(                  ,          p\*        P,                  P/                  RV/4      p\*        P,                  P1                  4       S n        \*        P,                  P5                  VS P2                  4      S n        R# )c                     \         P                  P                  4        \         P                  P                  V 4       R # r<   osenvironclearr|   old_environs   &r   restore_environ-ProxyAuthTests.setUp.<locals>.restore_environO  $    JJJJk*r   r   NO_PROXYno_proxyc                  6   < \        SP                  .V O5/ VB # r<   )r   r   )r   r   r   s   *,r   create_fake_proxy_handler7ProxyAuthTests.setUp.<locals>.create_fake_proxy_handlerZ  s    #D$<$<NtNvNNr   zhttp://127.0.0.1:%dr   N)r   r   r   r   r  r  copyrB   r   rQ   r   r   rU   r   r'   r   r   r   r-   r   r1   r   r   ProxyHandlerProxyDigestAuthHandlerproxy_digest_handlerr   opener)r   r  r  	proxy_urlhandlerr   s   f    r   r   ProxyAuthTests.setUpL  s@   nd)+	+ 	):;!#

:!#

:#4#6   **DIIt{{+CD  **4::6	O //HI(() )DKK,<,<<	..--v	.BC$*NN$I$I$K!nn11T..0r   c                H    V P                   P                  4        R V n         R # r<   r   r8   s   &r   r   ProxyAuthTests.stop_serverg  r   r   c                   V P                   P                  V P                  V P                  V P                  V P
                  R ,           4       V P                  P                  R4       V P                  \        P                  P                  4      ;_uu_ 4       pV P                  P                  V P                  4       RRR4       XP                  P                  4        R#   + '       g   i     L,; i)badrD   N)r  r   r   URLr   r   r   rM   r   r   r   r   r  openr   r   r   r   s   & r   -test_proxy_with_bad_password_raises_httperror<ProxyAuthTests.test_proxy_with_bad_password_raises_httperrork  s    !!..tzz488/3yy$++e:K	M  ((0v||5566"KKTXX& 7
 76s   &C$$C4	c                T   V P                   P                  R 4       V P                  \        P                  P
                  4      ;_uu_ 4       pV P                  P                  V P                  4       RRR4       XP                  P                  4        R#   + '       g   i     L,; irD   N)r   rM   r   r   r   r   r  r!  r   r   r   r"  s   & r   ,test_proxy_with_no_password_raises_httperror;ProxyAuthTests.test_proxy_with_no_password_raises_httperrors  sg      ((0v||5566"KKTXX& 7
 76s   &BB'	c                   V P                   P                  V P                  V P                  V P                  V P
                  4       V P                  P                  R 4       V P                  P                  V P                  4      ;_uu_ 4       pVP                  4       '       d   K   RRR4       R#   + '       g   i     R# ; ir&  )r  r   r   r   r   r   r   rM   r  r!  readr   results   & r   test_proxy_qop_auth_works(ProxyAuthTests.test_proxy_qop_auth_worksy  s    !!..tzz488/3yy$++	G  ((0[[dhh''6++--   ('''s   B3&B33C	c                   V P                   P                  V P                  V P                  V P                  V P
                  4       V P                  P                  R 4        V P                  P                  V P                  4      pT;_uu_ 4        VP                  4       '       d   K   RRR4       R#   + '       g   i     R# ; i  \        P                  P                   d     R# i ; i)zauth-intN)r  r   r   r   r   r   r   rM   r  r!  r*  r   r   URLErrorr+  s   & r   0test_proxy_qop_auth_int_works_or_throws_urlerror?ProxyAuthTests.test_proxy_qop_auth_int_works_or_throws_urlerror  s    !!..tzz488/3yy$++	G  ((4
	[[%%dhh/F kkmm $  ||$$ 	 		s$   #%C
 B6)B66C	
C-,C-)r   r  r  r   )r   r   r    r!   r   r   r   r   r   r   r#  r'  r-  r1  r"   r#   r   r   s   @@r   r   r   D  s<     
CDFE06 r   r   c                 X   a a  ! VV 3R  lR\         P                  P                  4      oS# )c                   R   <a  ] tR tRt o Rt. t. t^PtR tR t	VV3R lt
R tRtV tR# )	1GetRequestHandler.<locals>.FakeHTTPRequestHandler  z	TestHTTP/c                x    V P                  4       pV'       d"   V P                  P                  V4      pWR  pK)  R # r<   )	send_headr   r   )r   bodydones   &  r   r   8GetRequestHandler.<locals>.FakeHTTPRequestHandler.do_GET  s3    >>#Dzz''-E{ r   c                    V P                   R ,          pV P                  P                  \        V4      4      pV P	                  4        V P
                  P                  V4       R# )zContent-LengthN)r   rfiler*  intr   requestsr_   )r   content_length	post_datas   &  r   do_POST9GetRequestHandler.<locals>.FakeHTTPRequestHandler.do_POST  sC    !\\*:;N

N(;<IKKMMM  +r   c                  < V P                   Sn        V P                  P                  V P                  4       SP                  ^ 4      w  rpV P                  V4       V F)  w  rEV P                  WERV P                  /,          4       K+  	  V'       d%   V P                  RR4       V P                  4        V# V P                  4        R# )r   r1   r   z
text/plainN)
r   headers_receivedr?  r_   r   popr   r   r1   r   )r   response_coder   r9  headerrr   FakeHTTPRequestHandler	responsess   &     r   r8  ;GetRequestHandler.<locals>.FakeHTTPRequestHandler.send_head  s    6:ll"3MM  ++4==+;(MD}-#*  &1C)CD $+  >  "r   c                    R # r<   r   )r   r   s   &*r   r   =GetRequestHandler.<locals>.FakeHTTPRequestHandler.log_message  s    r   r   N)r   r   r    r!   server_versionr?  rE  r1   r   rB  r8  r   r"   r#   )r%   rI  rJ  s   @r   rI  r5    s3     $	#	,		 	r   rI  )r   r   r   )rJ  rI  s   f@r   GetRequestHandlerrO    s'    # #!C!C #L "!r   c                      a a ] tR tRt oV 3R ltRR ltR tRR ltRR l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VtV ;t# )TestUrlopeni  c                ,  < \         \        V `  4        V P                  \        P
                  P                  4       R  pV P                  V\        P                  P                  4       4       R\        P                  R&   R\        P                  R&   R# )c                     \         P                  P                  4        \         P                  P                  V 4       R # r<   r  r
  s   &r   r  *TestUrlopen.setUp.<locals>.restore_environ  r  r   *r  r  N)
r   rQ  r   r   r   r   
urlcleanupr  r  r  )r   r  r   s   & r   r   TestUrlopen.setUp  sd    k4&( 	112	+ 	):;!$

:!$

:r   c                   . p\         P                  P                  ! W3/ VB p VP                  VP	                  ^4      4       VP                  VP                  4       4       VP                  VP                  R4      4       VP                  VP                  4       4       VP                  4        RP                  V4      #   TP                  4        i ; i)r   i   r   )
r   r   r   extend	readlinesr_   readliner*  r   r6   )r   urldatar   lfs   &&&,  r   r   TestUrlopen.urlopen  s    NN""377	HHQ[[%&HHQZZ\"HHQVVD\"HHQVVXGGIxx{ GGIs   A>C Cc                H    V P                   P                  4        R V n         R # r<   r   r8   s   &r   r   TestUrlopen.stop_server  r   r   c                :   Vf   ^. R3.p\        V4      p\        V4      V n        V P                  V P                  4       V P                  P                  4        V P                  P                  P                  4        V P                  P                  pW2n        V# )Ns   we don't care)	rO  r'   r   r   r   r   r-   r   r1   )r   rJ  r  r1   s   &&  r   start_serverTestUrlopen.start_server  s    r#345I#I..w7(() {{r   c                    \        \        P                  R 4      '       g   V P                  R4       ^ RIHp Vf   ^. R3.p\        V4      pV! V 3RV/VB pVP                  Vn        V# )HTTPSHandlerzssl support required)make_https_server   we care a bithandler_class)hasattrr   r   skipTesttest.ssl_serversrh  rO  r1   )r   rJ  r   rh  r  r   s   &&,   r   start_https_serverTestUrlopen.start_https_server  sg    v~~~66MM016r#345I#I."4IwI&I{{r   c                    R pRR.R3^. V3.pV P                  V4      pV P                  RVP                  ,          4      pV P                  WA4       V P                  VP                  RR.4       R# )s   We got here...i.  r   http://localhost:%s//z/somewhere_elseN)Locationz(http://localhost:%(port)s/somewhere_elserd  r   r1   assertEqualr?  )r   expected_responserJ  r  r]  s   &    r   test_redirectionTestUrlopen.test_redirection  s    -KL"'(
	 ##I.||2W\\AB1))C1B+CDr   c                    R pRp^R.V3.pV P                  V4      pV P                  RVP                  ,          4      pV P                  WQ4       R# )s   hello worlds   a
hello worl
1
d
0
rq  N)zTransfer-Encodingchunked)rd  r   r1   ru  )r   rv  chunked_startr{   r  r]  s   &     r   test_chunkedTestUrlopen.test_chunked
  s]    *! 	 ;<mLM##H-||2W\\AB1r   c                   R pV P                  R. V3.4      p V P                  RVP                  ,          4       V P                  R4       V P                  XV4       V P                  VP                  R.4       R#   \        P
                  P                   d+   pTP                  4       pTP                  4         Rp?LuRp?ii ; i)s   Bad bad bad...r6  zhttp://localhost:%s/weeblez404 should raise URLErrorNz/weeble)rd  r   r1   r   r   r   r0  r*  r   ru  r?  )r   rv  r  r_  r]  s   &    r   test_404TestUrlopen.test_404  s    -##c2/@%A$BC	3LL5DE
 II1201))I;7 ||$$ 	668DGGII	s   "A= =C CCc                    R pV P                  ^. V3.4      pV P                  RVP                  ,          4      pV P                  W14       V P                  VP                  R.4       R# )   pycon 2008...http://localhost:%s/bizarre/bizarreNrt  r   rv  r  r]  s   &   r   test_200TestUrlopen.test_200'  sa    ,##c2/@%A$BC||9GLLHI1))J<8r   c                    R pV P                  ^. V3.4      pV P                  RVP                  ,          R4      pV P                  W14       V P                  VP                  RR.4       R# )r  r  s   get=with_feelingr  Nrt  r  s   &   r   test_200_with_parameters$TestUrlopen.test_200_with_parameters.  sj    ,##c2/@%A$BC||9GLLH021))J8K+LMr   c                    V P                  4       p\        P                  ! \        R 7      pV P	                  RVP
                  ,          VR7      pV P                  VR4       R# )cafilezhttps://localhost:%s/bizarrecontextri  N)rn  sslcreate_default_contextCERT_localhostr   r1   ru  )r   r  r  r]  s   &   r   
test_httpsTestUrlopen.test_https6  sN    ))+,,NC||:W\\ISZ|[/0r   c                  a \         f   V P                  R4       \         P                  '       g   V P                  R4       R oV3R lp\         P                  ! \         P                  4      pVP                  V4       V P                  V\        R7      p\         P                  ! \        R7      pV P                  RVP                  ,          VR7       V P                  SR4       R # )	Nzssl module requiredzSNI support required in OpenSSLc                    < VoR # r<   r   )ssl_sockserver_nameinitial_contextsni_names   &&&r   cb_sni*TestUrlopen.test_https_sni.<locals>.cb_sniB  s    "Hr   )r  certfiler  zhttps://localhost:%sr  	localhost)r  rl  HAS_SNI
SSLContextPROTOCOL_TLS_SERVERset_servername_callbackrn  r  r  r   r1   ru  )r   r  r  r  r  s   &   @r   test_https_sniTestUrlopen.test_https_sni<  s    ;MM/0{{{MM;<	# ..!8!89''/))'N)S,,NC+gll:GL;/r   c                \   V P                  4       p\        P                  P                  R VP                  ,          RR/R7      p\        P                  P                  V4      ;_uu_ 4         RRR4       V P                  VP                  R,          R4       R#   + '       g   i     L5; i)rq  Rangezbytes=20-39r   N)rd  r   r   Requestr1   r   ru  rE  r   r  reqs   &  r   test_sending_headers TestUrlopen.test_sending_headersL  s    ##%nn$$%;gll%J.5}-E % G^^##C(( )11':MJ )(s   ,BB+	c                   V P                  4       p\        P                  P                  R VP                  ,          RR/R7      p\        P                  P                  V4      ;_uu_ 4         RRR4       V P                  RVP                  P                  4       4       V P                  RVP                  P                  4       4       R#   + '       g   i     Lf; i)rq  zX-SoMe-hEaderfoobarr  NzX-Some-Header)
rd  r   r   r  r1   r   assertInrE  keysassertNotInr  s   &  r   test_sending_headers_camel&TestUrlopen.test_sending_headers_camelT  s    ##%nn$$%;gll%J.=x-H % J^^##C(( )ow'?'?'D'D'FG'*B*B*G*G*IJ )(s   ,CC	c                D   V P                  4       p\        P                  P                  R VP                  ,          4      ;_uu_ 4       pR F  pV P                  W#4       K  	  V P                  VP                  4       R4       RRR4       R#   + '       g   i     R# ; i)http://localhost:%szcalling 'read' failedN)r*  r   infogeturl)rd  r   r   r   r1   assertHasAttrr   r*  )r   r  open_urlattrs   &   r   
test_basicTestUrlopen.test_basic]  sn    ##%^^##$9GLL$HIIX;""82 <OOHMMO-DE JIIIs   	;BB	c                   V P                  4       p\        P                  P                  R VP                  ,          4      pV;_uu_ 4        VP                  4       pRRR4       V P                  X\        P                  P                  R4       V P                  VP                  4       R4       R#   + '       g   i     L]; i)r  NzEobject returned by 'info' is not an instance of email.message.Messageplain)rd  r   r   r   r1   r  assertIsInstanceemailmessageMessageru  get_content_subtype)r   r  r  info_objs   &   r   	test_infoTestUrlopen.test_infod  s    ##%>>))!GLL02X}}H h(=(=B	C 	557A Xs   B11C	c                8   V P                  4       p\        P                  P                  R VP                  ,          4      pV;_uu_ 4        VP                  4       pRRR4       V P                  XR VP                  ,          4       R#   + '       g   i     L5; i)r  N)rd  r   r   r   r1   r  ru  )r   r  r  r\  s   &   r   test_geturlTestUrlopen.test_geturlo  sf    ##%>>))*?',,*NOX//#C 3gllBC Xs   B		B	c                    R pV P                  ^. V3.4      p\        P                  P                  RVP                  ,          4      pV F  pV P                  WA4       K  	  R# )r  r  N)rd  r   r   r   r1   ru  )r   rv  r  r]  lines   &    r   test_iterationTestUrlopen.test_iterationw  sY    ,##c2/@%A$BC~~%%&;gll&JKDT5 r   c                   R RRRR,          R,           .pRP                  V4      pV P                  ^. V3.4      p\        P                  P	                  RVP
                  ,          4      p\        V4       FB  w  rVV P                  WaV,          RV: R	\        W,          4      : R
\        V4      : 24       KD  	  V P                  X^,           \        V4      4       R# )s   We
s   got
s   here
s	   verylong i       
r   r  zFetched line number z1 doesn't match expected:
    Expected length was z, got N)	r6   rd  r   r   r   r1   	enumerateru  r   )r   linesrv  r  r]  indexr  s   &      r   test_line_iterationTestUrlopen.test_line_iteration~  s    (I|d/BU/JKHHUO##c2/@%A$BC~~%%&;gll&JK$T?KET< $S%6D	CD +
 	CJ/r   c                   V P                  ^. R3^. R3.4      p\        P                  P                  4       p\        P                  P	                  RVP
                  ,          4      pV P                  RVP                  4       VP                  VRP                  R4      4       V P                  RVP                  4       V P                  RVP                  R4      4       VP                  VRP                  R4      4       V P                  R	VP                  4       V P                  R
VP                  R4      4       R# )r   s   anyr  N1zus-ascii   1zContent-length
1234567890s
   123456789010)rd  r   r   r   r  r1   ru  r]  r!  r]   
get_header)r   r  r  r   s   &   r   test_issue16464TestUrlopen.test_issue16464  s    ##"f"f%
  ,,...(()>)MNw||,GSZZ
34w||,g001ABCG\00<=5w112BCDr   )r   r<   )r   r   r    r!   r   r   r   rd  rn  rw  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r"   r#   r   r   s   @@r   rQ  rQ    sw     %	E289N10 KKF	BD6
0E Er   rQ  c                  |    \         P                  ! 4       p \        P                  ! \         P                  .V O5!   R # r<   )r   threading_setupunittestaddModuleCleanupthreading_cleanup)thread_infos    r   setUpModuler    s*    "224K.@@O;Or   __main__),r   r  r  urllib.parser   urllib.requesthttp.serverr   r)   r  rZ   testr   test.supportr   r   r  ImportErrorrequires_working_socketr   dirname__file__herer6   r  CERT_fakehostnamer   r   r	   r*   r'   rB   r   r   r   TestCaser   requires_hashdigestr   rO  rQ  r  r   mainr   r   r   <module>r     sz    	         ' )   t ,	wwx dJ>GGLLz>B 
)// )4(y// (6v vr&t{{99 &X;t{{99 ;B'X&& 'T ##E48JX&& J 9JZ("V^E(## ^E@P
 zMMO c  
Cs   F 	F%$F%