_mYy6JSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSK r SSK r SSK J r SSK Jr SSK Jr SSKJr SSKr\ R("SS9 \R*R-\5r\R*R3\SS 5r\R*R3\SS 5r"S S \R8R:5r"S S\R>5r "SS5r!"SS\R8RD5r#"SS\R8RD5r$"SS\ RJ5r&\RN"SSS9"SS\ RJ55r(Sr)"SS\ RJ\5r*Sr+\,S:Xa\ RZ"5 gg!\a SrGN_f=f) N)support)hashlib_helper)threading_helper)ExtraAssertionsT)modulecertdataz keycert.pemz keycert2.pemc$\rSrSrSrSrSrSrg)LoopbackHttpServer zVHTTP server w/ a few modifications that make it useful for loopback testing purposes. c[RRRUUU5 URR S5 g)Ng?)httpserver HTTPServer__init__socket settimeout)selfserver_addressRequestHandlerClasss A/opt/alt/python313/lib64/python3.13/test/test_urllib2_localnet.pyrLoopbackHttpServer.__init__%s6 ''(6(; = s#cbURR5upURS5 X4$)zHTTPServer method, overridden.g$@)racceptr)rrequestclient_addresss r get_requestLoopbackHttpServer.get_request.s2#'++"4"4"6 4 ((rN)__name__ __module__ __qualname____firstlineno____doc__rr__static_attributes__rrrr r s$ )rr c*\rSrSrSrSrSrSrSrg)LoopbackHttpServerThread:z2Stoppable thread that runs a loopback http server.c[RRU5 SUl[R"5UlSUl[SU5UlURRUl g)NFzHTTP/1.0)z 127.0.0.1r) threadingThreadr _stop_serverEventreadyprotocol_versionr httpd server_portportrrequest_handlers rr!LoopbackHttpServerThread.__init__=sW!!$'!__& +5('(8(79 JJ** rcfSUlUR5 URR5 g)z.Stops the webserver if it's currently running.TN)r,joinr0 server_closers rstopLoopbackHttpServerThread.stopFs%!  !rcURR5 UR(d.URR 5 UR(dM-ggN)r.setr,r0handle_requestr9s rrunLoopbackHttpServerThread.runNs7 ## JJ % % '###r)r,r0r2r.N) r r!r"r#r$rr:r@r%rrrr'r':s<+"(rr'cN\rSrSrSrSrSrSrSrSr Sr S r S r S r S rg )DigestAuthHandlerUz-Handler for performing digest authentication.cJSUl/Ul0UlSUlSUlg)Nrz Test Realmauth) _request_num_nonces_users _realm_name_qopr9s rrDigestAuthHandler.__init__Xs'  ' rcXlgr=)rK)rqops rset_qopDigestAuthHandler.set_qop_s rcXlgr=)rI)ruserss r set_usersDigestAuthHandler.set_usersbs rcXlgr=)rJ)rrealms r set_realmDigestAuthHandler.set_realmfs rcU=RS- sl[R"[UR5R S55R 5nUR RU5 U$)Nascii)rGhashlibmd5strencode hexdigestrHappend)rnonces r_generate_nonce!DigestAuthHandler._generate_nonceisW Q C 1 1299'BCMMO E" rc URS5nXS-SnURS5n0nUHRnURS5upgUR5nUSS:XaUSS:XaUSSnOUR5nXtU'MT U$)N rZ,=r")findsplitstrip)rauth_strfirst_space_indexparts auth_dictpartnamevalues r_create_auth_dict#DigestAuthHandler._create_auth_dictos$MM#.a/01s# D**S/KD::&3kk'..12<<>5546@A ;;|227;<FFHZ000rc $URSS5 URSS5 URSSUR<SUR<SUR 5<S 35 UR 5 UR RS 5 g ) NizProxy Authentication Required Content-Type text/htmlzProxy-AuthenticatezDigest realm="z", qop="z ",nonce="z", sProxy Authentication Required.F) send_response send_headerrJrKrc end_headerswfilewriter3s r_return_auth_challenge(DigestAuthHandler._return_auth_challenges}%%c+JK##NK@##   tyy$*>*>*@#B C ##%##$EFrc[UR5S:XagSUR;aURU5$UR URS5nUSUR;aURUSnOURU5$UR S5UR ;aURU5$UR RUS5 SnURUR4H*nURUUURU5(dM(SnM, U(dURU5$g)zPerforms digest authentication on the given HTTP request handler. Returns True if authentication was successful, False otherwise. If no users have been set, then digest auth is effectively disabled and this method will always return True. rTzProxy-AuthorizationusernamerbF) lenrIheadersrrugetrHremovepath short_pathrcommand)rr4rqrxauth_validatedrs rr? DigestAuthHandler.handle_requests1 t{{ q  (?(? ?..? ?..''(=>I$ 3;; *(=?22?CC==)T\\922?CC ##Ig$67"N )--/I/IJ&&y'/'6'>'>'+--&*N K"22?CCr)rHrKrJrGrIN)r r!r"r#r$rrOrSrWrcrurrr?r%rrrrCrCUs27! "1$ *rrCc\rSrSrSrSrSrSr\<S\<3r\ R"\RS55RS5r SrS rS rS rS rS rg)BasicAuthHandlerz,Handler for performing basic authentication.testUsertestPassTest:r[c`[RRR"U/UQ70UD6 gr=)r rBaseHTTPRequestHandlerr)rargskwargss rrBasicAuthHandler.__init__s$ **33DJ4J6Jrcgr=rrformatrs r log_messageBasicAuthHandler.log_messages rcjURS5 URSS5 UR5 g)N Content-typer)rrrr9s rdo_HEADBasicAuthHandler.do_HEADs, 3 5 rcURS5 URSSUR-5 URSS5 UR5 g)NizWWW-AuthenticatezBasic realm="%s"rr)rrREALMrr9s r do_AUTHHEADBasicAuthHandler.do_AUTHHEADsG 3 +-ADJJ-NO 5 rcURRSS5(d,UR5 URR S5 gURRSS5SUR -:Xa=UR S5 UR5 URR S5 gUR5 g)N AuthorizationsNo Auth header receivedzBasic rsIt works)rrrrr ENCODED_AUTHrrr9s rdo_GETBasicAuthHandler.do_GETs||44     JJ  7 8 \\  %(043D3D(DE   s #     JJ  [ )    rrN)r r!r"r#r$USERPASSWDr USER_PASSWDbase64 b64encoder_decoderrrrrrr%rrrrrs^6 D F E!6*K##K$6$6w$?@GGPLK   rrc*\rSrSrSrSrSrSrSrg)FakeProxyHandlerzThis is a 'fake proxy' that makes it look like the entire internet has gone down due to a sudden zombie invasion. It main utility is in providing us with authentication support for testing. clXl[RRR"U/UQ70UD6 gr=)digest_auth_handlerr rrr)rrrrs rrFakeProxyHandler.__init__s,$7  **33DJ4J6Jrcgr=rrs rrFakeProxyHandler.log_messages rc[RRURS5upp4pVX0lUR R U5(aURSS5 URSS5 UR5 URR[SUR-S55 URRS5 gg) Nr rOKrrzYou've reached %s!
r[sFOur apologies, but our server is down due to a sudden zombie invasion.) urllibparseurlparserrrr?rrrrrbytes)rscmnetlocrparamsqueryfragments rrFakeProxyHandler.do_GET s7=||7L7L IIv84dE  # # 2 24 8 8   sD )   ^[ 9     JJ  U#;dii#G#*, - JJ  : ; 9r)rrN) r r!r"r#r$rrrr%rrrrrs K  ;rrcV^\rSrSrSrSrSrSrU4SjrSr U4Sjr S r S r S r U=r$) BasicAuthTestsirr Incorrectrc>>[[U] 5 Sn[U5UlUR UR 5 SURR-UlURR5 URRR5 g)Nc[U0UD6$r=)r)rrs r#http_server_with_basic_auth_handlerABasicAuthTests.setUp..http_server_with_basic_auth_handler$s#T4V4 4rzhttp://127.0.0.1:%s) superrsetUpr'r addCleanup stop_serverr2 server_urlstartr.wait)rr __class__s rrBasicAuthTests.setUp!sp nd)+ 5./RS  (()/$++2B2BB   rcFURR5 SUlgr=rr:r9s rrBasicAuthTests.stop_server,  rc*>[[U] 5 gr=)rrtearDown)rrs rrBasicAuthTests.tearDown0s nd,.rc&[RR5nURURUR UR UR5 [RR[RRU55 UR[RRUR 55 g![RRa! URSUR -5 gf=f)Nz!Basic auth failed for the url: %s)rrHTTPBasicAuthHandler add_passwordrrrrinstall_opener build_opener assertTrueurlopenerror HTTPErrorfail)rahs rtest_basic_auth_success&BasicAuthTests.test_basic_auth_success3s ^^ 0 0 2  DOOTYY L%%fnn&A&A"&EF M OOFNN224??C D||%% M II9DOOK L Ms8C^[[T] 5 SnTRU[R R 55 S[R S'S[R S'[5TlTRRTRTR05 TRRTR5 U4Sjn[U5TlTRTR 5 TRR#5 TRR$R'5 STRR(-n[*R,R/SU05n[*R,R15Tl[*R,R5UTR25Tlg)Nc~[RR5 [RRU5 gr=osenvironclearr~ old_environs rrestore_environ-ProxyAuthTests.setUp..restore_environP$ JJ    JJ  k *rrNO_PROXYno_proxyc6>[TR/UQ70UD6$r=)rr)rrrs rcreate_fake_proxy_handler7ProxyAuthTests.setUp..create_fake_proxy_handler[s#D$<$<NtNvN Nrzhttp://127.0.0.1:%dr )rrrrr r copyrCrrSrrrWrr'rrrr.rr2rr ProxyHandlerProxyDigestAuthHandlerproxy_digest_handlerropener)rrr proxy_urlhandlerrs` rrProxyAuthTests.setUpMs@ nd)+ + ):;!# :!# :#4#6    **DIIt{{+CD   **4::6 O//HI  (()   )DKK,<,<< ..--v .BC$*NN$I$I$K!nn11 T..0 rcFURR5 SUlgr=rr9s rrProxyAuthTests.stop_serverhrrcURRURURURUR S-5 UR RS5 UR[RR5nURRUR5 SSS5 WRR5 g!,(df  N)=f)NbadrF)rrrURLrrrrOrrrrropenrrrrs r-test_proxy_with_bad_password_raises_httperrorURRS5 UR[RR 5nUR RUR5 SSS5 WRR5 g!,(df  N)=fNrF) rrOrrrrrr%r$rrr&s r,test_proxy_with_no_password_raises_httperror;ProxyAuthTests.test_proxy_with_no_password_raises_httperrortsd   ((0   v||55 6" KK  TXX &7 7 6s &B BcURRURURURUR 5 UR RS5 URRUR5nUR5(aUR5(aMSSS5 g!,(df  g=fr*) rrrr$rrrrOrr%readrresults rtest_proxy_qop_auth_works(ProxyAuthTests.test_proxy_qop_auth_workszs !!..tzz488/3yy$++ G   ((0 [[  dhh '6++--++--( ' 's ,B>> C cURRURURURUR 5 UR RS5 URRUR5nU UR5(aUR5(aMSSS5 g!,(df  g=f![RRa gf=f)Nzauth-int)rrrr$rrrrOrr%r.rrURLErrorr/s r0test_proxy_qop_auth_int_works_or_throws_urlerror?ProxyAuthTests.test_proxy_qop_auth_int_works_or_throws_urlerrors !!..tzz488/3yy$++ G   ((4 [[%%dhh/Fkkmmkkmm ||$$    s#%C ,C CC32C3)rrrr)r r!r"r#r$rrrrrr'r+r1r5r%rrs@rrrEs: C D F E06 rrcX^^"UU4SjS[RR5mT$)NcF>\rSrSrSr/r/rSrSrSr UU4Sjr Sr Sr g ) 1GetRequestHandler..FakeHTTPRequestHandleriz TestHTTP/PcUR5nU(a)URRU5nXSnU(aM(ggr=) send_headrr)rbodydones rr8GetRequestHandler..FakeHTTPRequestHandler.do_GETs5>>#Dzz''-E{$rcURSnURR[U55nUR 5 UR R U5 g)NzContent-Length)rrfiler.intrrequestsra)rcontent_length post_datas rdo_POST9GetRequestHandler..FakeHTTPRequestHandler.do_POSTsC!\\*:;N N(;URTlURRUR5 TR S5upnUR U5 UH%upEURXESUR0-5 M' U(a$URSS5 UR5 U$UR5 g)Nrr2rz text/plain) rheaders_receivedrCrarpoprrr2r)r response_coderr=headerrtFakeHTTPRequestHandler responsess rr<;GetRequestHandler..FakeHTTPRequestHandler.send_heads6:ll " 3 MM  ++4==+; (MD   } -#*  &1C)CD$+  >  "    rcgr=r)rrs rr=GetRequestHandler..FakeHTTPRequestHandler.log_messages rrN) r r!r"r#server_versionrCrIr2rrFr<rr%)rMrNsrrMr9s,$ #  ,  rrM)r rr)rNrMs`@rGetRequestHandlerrSs'##!C!C#L "!rc^\rSrSrSrU4SjrSSjrSrSSjrSSjr Sr S r S r S r S rS rSrSrSrSrSrSrSrSrSrSrU=r$) TestUrlopenia:Tests urllib.request.urlopen using the network. These tests are not exhaustive. Assuming that testing using files does a good job overall of some of the basic interface features. There are no tests exercising the optional 'data' and 'proxies' arguments. No tests for transparent redirection have been written. c*>[[U] 5 UR[R R 5 SnURU[RR55 S[RS'S[RS'g)Nc~[RR5 [RRU5 gr=r rs rr*TestUrlopen.setUp..restore_environrr*rr) rrUrrrr urlcleanupr r r)rrrs rrTestUrlopen.setUpsd k4&( 112 + ):;!$ :!$ :rc /n[RR"X40UD6nURUR S55 UR UR 55 UR URS55 UR UR55 UR5 SRU5$!UR5 f=f)Nrir) rrrextend readlinesrareadliner.rr7)rurldatarlfs rrTestUrlopen.urlopens  NN " "3 7 7  HHQ[[% & HHQZZ\ " HHQVVD\ " HHQVVX  GGIxx{ GGIs A>CCcFURR5 SUlgr=rr9s rrTestUrlopen.stop_serverrrc8UcS/S4/n[U5n[U5UlURUR5 URR 5 URR R5 URRnX2lU$)Nrs we don't care) rSr'rrrrr.rr2)rrNrr2s r start_serverTestUrlopen.start_servers  r#345I#I..w7  (()   {{ rc [[RS5(dURS5 SSKJn UcS/S4/n[ U5nU"U4SU0UD6nURUlU$)N HTTPSHandlerzssl support requiredr)make_https_serverr we care a bit handler_class)hasattrrrskipTesttest.ssl_serversrlrSr2)rrNrrlrrs rstart_https_serverTestUrlopen.start_https_serversgv~~~66 MM0 16  r#345I#I."4IwI&I{{ rcSnSS/S4S/U4/nURU5nURSUR-5nURXA5 URURSS/5 g) NsWe got here...i.)Locationz(http://localhost:%(port)s/somewhere_elserrhttp://localhost:%s//z/somewhere_elserhrr2 assertEqualrC)rexpected_responserNrras rtest_redirectionTestUrlopen.test_redirections- KL   "' ( ##I.||2W\\AB 1 ))C1B+CDrcSnSnSS/U4/nURU5nURSUR-5nURXQ5 g)Ns hello worldsa hello worl 1 d 0 r)zTransfer-Encodingchunkedrv)rhrr2ry)rrz chunked_startr}rras r test_chunkedTestUrlopen.test_chunked s]*! ;Umgr=r)ssl_sock server_nameinitial_contextsni_names rcb_sni*TestUrlopen.test_https_sni..cb_sniCs"Hr)rcertfilerzhttps://localhost:%sr localhost) rrpHAS_SNI SSLContextPROTOCOL_TLS_SERVERset_servername_callbackrrrrrr2ry)rrrrrs @rtest_https_sniTestUrlopen.test_https_sni=s ; MM/ 0{{ MM; < #..!8!89''/))'N)S,,NC +gll:G L ;/rc0UR5n[RRSUR-SS0S9n[RR U5 SSS5 UR URSS5 g!,(df  N.=f)NrvRangez bytes=20-39r)rhrrRequestr2rryrIrrreqs rtest_sending_headers TestUrlopen.test_sending_headersMs|##%nn$$%;gll%J.5}-E%G ^^ # #C ( ) 11':MJ) (s B BcUR5n[RRSUR-SS0S9n[RR U5 SSS5 UR SURR55 URSURR55 g!,(df  Nc=f)Nrvz X-SoMe-hEaderfoobarrz X-Some-Header) rhrrrr2rassertInrIkeys assertNotInrs rtest_sending_headers_camel&TestUrlopen.test_sending_headers_camelUs##%nn$$%;gll%J.=x-H%J ^^ # #C ( ) ow'?'?'D'D'FG '*B*B*G*G*IJ) (s B<< C c$UR5n[RRSUR-5nSHnUR X#5 M UR UR5S5 SSS5 g!,(df  g=f)Nhttp://localhost:%s)r.rinfogeturlzcalling 'read' failed)rhrrrr2 assertHasAttrrr.)rropen_urlattrs r test_basicTestUrlopen.test_basic^sh##% ^^ # #$9GLL$H IX;""82< OOHMMO-D EJ I Is ;B BcjUR5n[RRSUR-5nU UR 5nSSS5 UR W[RRS5 URUR5S5 g!,(df  NZ=f)NrzEobject returned by 'info' is not an instance of email.message.Messageplain) rhrrrr2rassertIsInstanceemailmessageMessageryget_content_subtype)rrrinfo_objs r test_infoTestUrlopen.test_infoes##%>>)) !GLL 02 }}H h (=(=B C 557A Xs B$$ B2cUR5n[RRSUR-5nU UR 5nSSS5 UR WSUR-5 g!,(df  N.=f)Nr)rhrrrr2rry)rrrr`s r test_geturlTestUrlopen.test_geturlpsd##%>>))*?',,*NO //#C 3gllBCXs A88 BcSnURS/U4/5n[RRSUR-5nUHnUR XA5 M g)Nrrr)rhrrrr2ry)rrzrralines rtest_iterationTestUrlopen.test_iterationxsY,##c2/@%A$BC~~%%&;gll&JKD   T 5rc SSSSS-S-/nSRU5nURS/U4/5n[RR S UR -5n[ U5H:upVURXaUS U<S [X5<S [U5<35 M< URWS -[U55 g)NsWe sgot shere s verylong i  rrrzFetched line number z1 doesn't match expected: Expected length was z, got rZ) r7rhrrrr2 enumerateryr)rlinesrzrraindexrs rtest_line_iterationTestUrlopen.test_line_iterations(I|d/BU/JKHHUO##c2/@%A$BC~~%%&;gll&JK$T?KE   T<$S%6D C D+ CJ/rczURS/S4S/S4/5n[RR5n[RR SUR -5nUR SUR5 URUSRS55 UR SUR5 UR SURS55 URUSRS55 UR S UR5 UR S URS55 g) Nrsanyr1zus-ascii1zContent-length 1234567890s 123456789010) rhrrrrr2ryrar%r_ get_header)rrrrs rtest_issue16464TestUrlopen.test_issue16464s## "f  "f %  ,,...(()>)MN w||, GSZZ 34 w||, g001ABC G\00<=  5 w112BCDr)rr=)r r!r"r#r$rrrrhrrr{rrrrrrrrrrrrrrr%rrs@rrUrUsz %    E 2 89N1 0 KKF BD6 0EErrUcx[R"5n[R"[R/UQ76 gr=)rthreading_setupunittestaddModuleCleanupthreading_cleanup) thread_infos r setUpModulers*"224K .@@O;Or__main__).rr r urllib.parserurllib.request http.serverr r*rr\testr test.supportrrtest.support.testcaserr ImportErrorrequires_working_socketrdirname__file__herer7rCERT_fakehostnamerrr r+r'rCrrrTestCaserrequires_hashdigestrrSrUrr mainrrrrs ')1t, wwx dJ >GGLLz>B )//)4(y//(6vvr&t{{99&X;t{{99;B'X&&'T##E48JX&&J9JZ("V^E(##_^E@P  z MMOc CsFF"!F"