KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17
System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64
User : nobody ( 99)
PHP Version : 5.2.17
Disable Function : NONE
Directory :  /proc/21585/root/usr/lib/python2.4/test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/21585/root/usr/lib/python2.4/test/test_urllib2.pyc
m
=5Dc@sdkZdklZdkZdkZdkZdkZdklZlZdei	fdYZ
dfdYZdfdYZd	e
fd
YZdeifdYZd
fdYZdfdYZdfdYZdZdei	fdYZdZdei	fdYZdei	fdYZdei	fdYZedZedjoedendS( N(stest_support(sRequestsOpenerDirectortTrivialTestscBstZdZdZRS(NcCs|ittidtiitii	dd}|dd!djo|d}ntidjod|i	dd}nHtidjo7dk}ti
|}|i|id	d
}nd|}ti|}|i}|idS(Ns	bogus urls\t/iit:tmactriscoss/.s./s	file://%s(tselftassertRaisest
ValueErrorturllib2turlopentostpathtabspatht__file__treplacetfnametnametstringtexpandt	translatet	maketranstfile_urltftreadtbuftclose(RRRRRR((t'/usr/lib/python2.4/test/test_urllib2.pyttest_trivials!	
c
Csddddgfdddgfdddd	d
ddd
gfddddgfg}x-|D]%\}}|iti||q^WdS(Nsa,b,ctatbtcspath"o,l"og"i"cal, examplespath"o,l"og"i"caltexamplesa, b, "c", "d", "e,f", g, hs"c"s"d"s"e,f"tgthsa="b\"c", d="e\,f", g="h\\i"sa="b"c"sd="e,f"sg="h\i"(ttestsRtlistRtassertEqualsRtparse_http_list(RR#R"R((Rttest_parse_http_list,sW(t__name__t
__module__RR&(((RRs	t
MockOpenercBs#tZgZddZdZRS(NcCs|||_|_dS(N(treqtdataR(RR*R+((Rtopen7scGs|||_|_dS(N(tprototargsR(RR-R.((Rterror9s(R'R(t
addheaderstNoneR,R/(((RR)5stMockFilecBs)tZddZddZdZRS(NcCsdS(N((Rtcount((RR=scCsdS(N((RR3((Rtreadline>scCsdS(N((R((RR?s(R'R(R1RR4R(((RR2<stMockHeaderscBstZdZRS(NcCs
|iS(N(Rtvalues(RR((Rt
getheadersBs(R'R(R7(((RR5AstMockResponsecBs&tZddZdZdZRS(NcCsAtii||||||f\|_|_|_|_dS(N(tStringIOt__init__RR+tcodetmsgtheadersturl(RR;R<R=R+R>((RR:FscCs|iS(N(RR=(R((RtinfoIscCs|iS(N(RR>(R((RtgeturlKs(R'R(R1R:R?R@(((RR8Es	t
MockCookieJarcBstZdZdZRS(NcCs
||_dS(N(trequestRtach_req(RRB((Rtadd_cookie_headerOscCs|||_|_dS(N(RBtresponseRtec_reqtec_r(RRERB((Rtextract_cookiesQs(R'R(RDRH(((RRANs	t
FakeMethodcBstZdZdZRS(NcCs||_||_||_dS(N(t	meth_nameRthandletaction(RRJRLRK((RR:Us		cGs|i|i|i|S(N(RRKRJRLR.(RR.((Rt__call__Ys(R'R(R:RM(((RRITs	tMockHandlercBsDtZdZdZdZdZdZdZdZRS(NicCs|i|dS(N(Rt_define_methodstmethods(RRP((RR:^scCsmxf|D]^}t|djo|\}}n|d}}t|||i}t
|i||qWdS(Ni(RPtspectlenRRLR1RIRRKtmethtsetattrt	__class__(RRPRRLRSRQ((RRO`s
cOsI|iii||||f|djodSn|djo|Sn|djot	ddhd}|Sn|djotdSn|idoy||i
d	d
}yt|}Wntj
onXt	ddhd}|iid|d||dhSn!|d
jotidntptdS(Nsreturn selfsreturn responseitOKtsreturn requestshttp://blah/R/t ithttpitraisetblah(Rtparenttcallstappendtfn_nameR.tkwdsRLR1R8trestRequestt
startswithtrfindR;tintRR/RtURLErrortFalsetAssertionError(RR_RLR.R`R;Ra((RRKfs*



'
cCsdS(N((R((RR|scCs||_g|i_dS(N(R\RR](RR\((Rt
add_parent}s	cCs(t|dptSn|i|ijS(Nt
handler_order(thasattrtothertTrueRRj(RRl((Rt__lt__s(	R'R(RjR:RORKRRiRn(((RRN\s					cCsg}d}xp|D]h}dtfdY}||}|i|7_|i||d}|i
||i|qW|S(sCreate 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.

    itMockHandlerSubclasscBstZRS(N(R'R((((RRosiN(thandlersR3t	meth_spectmethsRNRoR!RjRitopenerR^tadd_handler(RsRqR3RpR!RrRo((Rtadd_ordered_mock_handlerss


tOpenerDirectorTestscBs5tZdZdZdZdZdZRS(Nc
Cst}dddgdgdgd	gg}t||}td}|i|}	|i
|	|d|ddf|ddfg}x[t||iD]G\}
}|\}}}}|i
||f|
|i
||fqWdS(
Nt	http_opentftp_openthttp_error_302sreturn selfshttp://example.com/ii(s	http_opensreturn self(s	http_opensreturn self(tOpenerDirectortoRqRuRpRbR*R,trRtassertEqualR]tziptexpectedtgotthandlerRR.R`(
RR.R]RpRR*R{R`RqR|RRR((Rttest_handleds	$ cCst}g}xqd	gdfdgdfgD]Q\}}dtfdY}||}||_|i||i	|q.W|i
d}|i
|idd|d|i
|idd|ddS(
NRwsreturn selfiiRocBstZRS(N(R'R((((RRosshttp://example.com/i(s	http_opensreturn self(RzR{RpRrRjRNRoR!R^RtR,R|RR}R](RRjRpR!RrR{RoR|((Rttest_handler_orders		
cCs|t}dgdgg}t||}td}|it	i
|i||i|i
|dd|fhfgdS(NRwRZsreturn selfshttp://example.com/i(s	http_opensraise(s	http_opensreturn self(RzR{RqRuRpRbR*RRRRfR,R}R](RRpR*R{Rq((Rt
test_raises	c
Cs)t}dgddgdddgdgg}	t||	}d	fd
Y}td}|i|}
t
|idjpt|d
d|ff|dd||ddhffg}x]t
||iD]I\}}|\}}}|i||f|d |i||dqWdS(NRws	error 302thttp_error_400RZRysreturn responsethttp_error_303t
http_errortUnknowncBstZdZRS(NcCstS(N(Rm(RRl((Rt__eq__s(R'R(R(((RRsshttp://example.com/iii.RW(s	http_opens	error 302(Rsraise(shttp_error_302sreturn response(RzR{RqRuRpRRbR*R,R|RRR]RhR~RRRtmethod_nameR.RR}(
RR.R]RpRRR*R{RRqR|RR((Rttest_http_errors	';cCst}d	d
gddgg}	t||	}td}|i|}
|ddf|ddf|ddf|ddfg}xt
|i	D]\}\}}}}|djoN|i||f|||it|d|it|dtq|i||f|||it|d|it|dt|i|ddjpt|dtqWdS(
Nthttp_requestsreturn requestt
http_responsesreturn responseshttp://example.com/iii(Rsreturn request(Rsreturn response(Rsreturn request(Rsreturn response(RzR{RqRuRpRbR*R,R|R]t	enumeratetiRRR.R`RR}RRtassert_t
isinstanceR1R8(RR.RR]RpRRR*R{RqR|R`((Rttest_processorss 	:
(R'R(RRRRR(((RRvs
				cCsJdk}|i|}tidjo|ido|d}n|S(Ntnts///i(turllibtpathname2urlRturlpathR
RRc(RRR((Rtsanepathname2url#s
	 tHandlerTestscBsktZdZdZdZdZdZdZdZdZ	d	Z
d
ZdZRS(Nc	sdfdYdtifdY}dk}dk}
d}||}t}
|_
xodd|idd	d
gddfd
dddd	d
gddfdd|idgddfgD]
\}}}}}}}	|it|}|i|i|ijo
djn|i|i|
i||i|i||i|i||i|ii||i|ii||i}|i|i!d|	|it"|dt#|qWdS(NtMockFTPWrappercBstZdZdZRS(NcCs
||_dS(N(R+R(RR+((RR:/scCs2|||_|_ti|it|ifS(N(tfilenametfiletypeRR9R+RR(RRR((Rtretrfile0s(R'R(R:R(((RR.s	tNullFTPHandlercstZdZdZRS(NcCs
||_dS(N(R+R(RR+((RR:5scsH|||_|_|||_|_||_|i|_|iS(N(	tusertpasswdRthosttporttdirsRR+t
ftpwrapper(RRRRRR(R(Rtconnect_ftp6s
	(R'R(R:R((R(RR4s	srheum rhaponicums ftp://localhost/foo/bar/baz.htmlt	localhosttItfootbarsbaz.htmls	text/htmlsftp://localhost:80/foo/bar/iPtDRWsftp://localhost/baz.gif;type=atAsbaz.gifsContent-typesContent-length($RRt
FTPHandlerRtftplibtsocketR+R!R)R{R\tFTP_PORTR1R>RRttype_RRtmimetypeRxRbR|RRRRR}t
gethostbynameRRR?R=tgetReRR(RRRRRRRRR+RRR>R!R{R=RR|((RRttest_ftp-s$	a*cCsdk}dk}dk}
ti}
t}|
_t	i
}	tti
i|	}d}xId|d|d|
id|fd|
i|
i|fgD]}t|	d}zz|i|Wd|iX|
it|}z(|i}|i}|i}Wd|iXti!|	}|i#|i$}Wdti&|	X|i(|||i(|dd|i(|d	d
|i(|d|qWxwd|gD]h}zQt|	d}z|i|Wd|iX|i)ti*|
it|Wdti&|	XqWti}
t}|
_xd
t+fdt,fdt,fgD]\}}t|}y|
i|Wn*ti*t/fj
o|i0|qbX|i0|i.|j|i(|i1dqbWdS(Ns
hello, world
sfile://localhost%ss	file://%ssfile://%s%sRtwbsContent-types
text/plainsContent-lengtht13s
Last-modifiedsfile://localhost:80%ssfile://ftp.example.com//foo.txts file://ftp.example.com///foo.txtsfile://ftp.example.com/foo.txttftp(2ttimetrfc822RRtFileHandlerR!R)R{R\ttest_supporttTESTFNRR
RRRttowriteRtgethostnameR>R,RtwriteRt	file_openRbR|RR+R?R=R@tnewurltstattstatst
formatdatetst_mtimetmodifiedtremoveRR}RRfRmRgRR*tOSErrorRttype(RRRRRR*RRR+RRRR>R!RR{R=R|R((Rt	test_fileYsh	G"c
sKdfdYdfdY}ti}t}|_d}x@ddgD]2\}}
t||
hd	d
<}|idd|}|i||}	|	i|	i|	i|	i|	i|	id
jdf|	i}|i|i|i|	i||i|id|i|id|i|i
||i|id|i|i ddd g|i|i|
qXWt!|_"|i#ti$|i||d!g|_%xd"D]}}
td|
}t&d
dhd}	|i'|}|
djo0|i)d|i*j|i)d|i*jn/|i|i*dd|i|i*dd|i|i*dd|i|i*dd|idd|idd
|idd|idd|i'|}|i|i*dd|i|i*dd
|i|i*dd|i|i*ddqWdS(#NtMockHTTPResponsecBstZdZdZRS(NcCs(||_||_||_||_dS(N(tfpRR<tstatustreason(RRR<RR((RR:s			cCsdS(NRW((R((RRs(R'R(R:R(((RRs	t
MockHTTPClasscs>tZdZdZdZdhdZdZRS(NcCsg|_d|_t|_dS(N(Rtreq_headersR1R+Rgtraise_on_endheaders(R((RR:s		cCs
||_|S(N(RR(RR((RRMs	cCs
||_dS(N(tlevelR(RR((Rtset_debuglevelscCso||_||_|i|i7_|ii|o
||_	n|i
odk}|indS(N(
tmethodRR>tselectorRR=titemstsorttbodyR+RRR/(RRR>RR=R((RRBs		


	csthddS(NiRV(RR2(R(R(Rtgetresponses(R'R(R:RMRR1RBR((R(RRs
			
shttp://example.com/tGETtPOSTR[tFooRtSpamteggsiRVsexample.comiRt
ConnectionRRWsContent-lengthsContent-typet0s!application/x-www-form-urlencodedtHostRtbaz(RN(Rsblah(Rsclose(Rsbar(RR(RR(RWN(+RRRtAbstractHTTPHandlerR!R)R{R\R>R1RR+RbR*tadd_unredirected_headerRYtdo_openR|RR4R?R@R;R<thdrsRthas_keyRR}RRRRRmRRRfR0R8tdo_request_tnewreqRtunredirected_hdrs(
RRRYRR>R!R*R{RR|R+RR((RRt	test_httpsb
		
cCsti}t}|_d}t|}t	ddhd|}|i||}|i||j|it|dt	ddhd|}|i|i||dj|i|id|i|i||ddhfdS(	Nshttp://example.com/iRVRWR-itCreatedRY(RtHTTPErrorProcessorR!R)R{R\R>RbR*R8R|RtnewrRRRkR1R}R-R.(RR>R!R*R{R|R((Rttest_errorsscCst}ti|}t}|_td}t
ddhd}|i|}|i|i|jo
|jn|i|id|i|i|i||}|i|i|j|i|i|jo
|jndS(Nshttp://example.com/iRVRWsexample.com(RAtcjRtHTTPCookieProcessorR!R)R{R\RbR*R8R|RRRRRCR$tget_origin_req_hosttis_unverifiableRRRFRG(RRRR!R*R{R|R((Rttest_cookiess	'cCsd}d}
ti}t}|_xudD]m}xddD]\}t|d|}	t
||}|id	d
|iddy,|	|t|d
thd|
<Wn6tij
o'|i|djo
|dj	nX|i|ii|
y|i|iidWn*tj
o|i|iinX|i|iid	d
|id|iij|id|iijq<Wq/Wt
|}|
d}t
|dd}d}y&x|||d|d}qWWn,tij
o|i|tiinXt
|dd}d}y*x#|||d||d}qCWWn,tij
o|i|tii nXdS(Nshttp://example.com/a.htmlshttp://example.com/b.htmli-i.i/i3s
blah
blah
s
http_error_%stNonsensesviking=withholdRtspamtBlahtlocationRc
Cs/|i|tddthd|<dS(Ni.RR(R!RyR*R2R5R>(R!R*R>((RtredirectFstorigin_req_hostsexample.comiishttp://example.com/shttp://example.com/%d(i-i.i/i3(Ns
blah
blah
(!tfrom_urltto_urlRtHTTPRedirectHandlerR!R)R{R\R;R1R+tgetattrRRbR*t
add_headerRR2R5t	HTTPErrorRRR}tget_full_urlt
get_methodtAttributeErrorthas_dataR=RRR3tmax_repeatstmax_redirections(RRR;R3R!R*R{RR+RR((Rt
test_redirect's^%!	c
Csd}	dddg}dddg}d}ti}t}|_	t
|	}xS|D]K}
|
d	|}|iti|i|td
dthd|<qYWx`|D]X}
|
d	|}|i|td
d
thd|<|i|ii|qWdS(Nshttp://example.com/a.htmlRYthttpsRtfiletimaptldapsexample.com/b.htmls://i.sSecurity LoopholeRsThat's fine(Rt
valid_schemestinvalid_schemestschemeless_urlRRR!R)R{R\RbR*tschemetinvalid_urlRRRRyR2R5t	valid_urlR}R(RRR!RR*R{RR
RRR((Rttest_invalid_redirectbs&cCsdtifdY}
dkl}dkl}l}l}	l}dkl	}|}||dd|
}||}|||}|id|i|iiddS(	NtMockHTTPHandlercBstZdZdZRS(NcCs
d|_dS(Ni(Rt_count(R((RR:xscCsdk}dkl}|idjoK|id|_|i|d}|iid|t	dd|Sn;||_|i|d}t
d	d
|d|iSdS(N(sStringIOiis%Location: http://www.cracker.com/

RYi.tFounds

iRVRW(t	mimetoolsR9RRtMessageR<R\R/R*R2R8R(RR*RR9R<((RRwys	
&	(R'R(R:Rw(((RRws	(s	CookieJar(sbuild_openersHTTPHandlers	HTTPErrorsHTTPCookieProcessor(sinteract_netscapeshttp://www.example.com/s	spam=eggstCookie(RtHTTPHandlerRt	cookielibt	CookieJartbuild_openerRRttest_cookielibtinteract_netscapeRthhtcpR{R,RRR*t
has_header(RRRRRR{RRRRRR((Rttest_cookie_redirectvs

		
c	Cst}titdd}|i|d	gg}t||}t
d}|i
|id|i|}|i
|id|i
|ddfgg}|iD]}||dd!q~dS(
NRYsproxy.example.com:3128Rwsreturn responseshttp://acme.example.com/sacme.example.comii(s	http_opensreturn response(RzR{RtProxyHandlertdicttphRtRqRuRpRbR*RR}tget_hostR,R|t_[1]R]ttup(	RRpR'R*R{R&RqR|R$((Rt
test_proxys	
cCsdtid<t}titdd}|i|t	d}|i|i
d|i|}|i|i
dt	d}|i|i
d|i|}|i|i
dtid=dS(	Ns
python.orgtno_proxyRYsproxy.example.comshttp://www.perl.org/swww.perl.orgshttp://www.python.orgswww.python.org(R
tenvironRzR{RR"R#R$RtRbR*RR}R%R,R|(RR*R{R|R$((Rttest_proxy_no_proxys
	
c	Cst}titdd}|i|d	gg}t||}t
d}|i
|id|i|}|i
|id|i
|ddfgg}|iD]}||dd!q~dS(
NRsproxy.example.com:3128t
https_opensreturn responseshttps://www.example.com/swww.example.comii(R,sreturn response(RzR{RR"R#R$RtRqRuRpRbR*RR}R%R,R|R&R]R'(	RRpR'R*R{R&RqR|R$((Rttest_proxy_httpss	
(
R'R(RRRRRRRR!R(R+R-(((RR+s	,	S	[			;				t	MiscTestscBstZdZdZRS(NcCs8dtifdY}dtifdY}dtifdY}ti}|||}|i	|||i	|||||}|i	|||i	||||}|i	|||}|i	|ti|ti}|i	|ti|ti}|i	|tidS(Nt
MyHTTPHandlercBstZRS(N(R'R((((RR/st
FooHandlercBstZdZRS(NcCsdS(N((R((Rtfoo_opens(R'R(R1(((RR0st
BarHandlercBstZdZRS(NcCsdS(N((R((Rtbar_opens(R'R(R3(((RR2s(
RRR/tBaseHandlerR0R2RR{Rtopener_has_handler(RRR0R{R/R2((Rttest_build_openers$		cCs:x3|iD]}|i|joPq
q
W|itdS(N(RsRpR!RUt
handler_classRRRg(RRsR7R!((RR5s

	(R'R(R6R5(((RR.s	tNetworkTestscBsPtZdZdZdZdZdZdZdZdZ	RS(	NcCsdS(N((R((RtsetUpscCsStiddhdd<}ti|}|i}|it	|ddS(Nshttp://www.python.orgR=tRangesbytes=20-39i(
RRbR*R	tresultRR+RR}RR(RR*R;R+((Rt
test_ranges
	cCs)dddg}|i||idS(Ns-ftp://www.python.org/pub/python/misc/sousa.aus!ftp://www.python.org/pub/tmp/blats[ftp://gatekeeper.research.compaq.com/pub/DEC/SRC/research-reports/00README-Legal-Rules-Regs(turlsRt
_test_urlst_extra_handlers(RR=((RRscCs&ddg}|i||idS(Ns3gopher://gopher.lib.ncsu.edu/11/library/stacks/Alexs"gopher://gopher.vt.edu:10010/10/33(R=RR>R?(RR=((Rttest_gopherscCsti}t|d}ze|id|idttii	|ddtti
ffg}|i||iWdti|XdS(Ntws	hi there
sfile:sfile://nonsensename/etc/passwd(RRR,RRRRR
RRR1RRR/R=RR>R?R(RRR=R((RRs	

4cCs,ddddg}|i||idS(Nshttp://www.espn.com/s)http://www.python.org/Spanish/Inquistion/s%http://www.python.org/cgi-bin/faqw.pys:query=pythonistas&querytype=simple&casefold=yes&req=searchshttp://www.python.org/(s%http://www.python.org/cgi-bin/faqw.pys:query=pythonistas&querytype=simple&casefold=yes&req=searchN(R1R=RR>R?(RR=((RR!sc
Cs5dk}dk}
dk}|idi}titi|x|D]}t|to|\}}}nd}}||yti||}WnLt|itfj
o4}	||	|o|it|	|qn,X|i}|i|dt||d|
idqJWdS(Nttest_urllib2s
read %d bytess******** next url coming up...f0.10000000000000001(RRtloggingt	getLoggertdebugRtinstall_openerRRpR=R>RttupleR*texpected_errR1R	RtIOErrorR/RterrRRRRRRRtsleep(
RR=RpRHR*RCRRR>RJRRER((RR>Gs,			




cCs@g}|ititi}|id|i||S(Ni(RpR^Rt
GopherHandlertCacheFTPHandlertcfht
setTimeout(RRNRp((RR?bs

(
R'R(R9R<RR@RRR>R?(((RR8s		
					&	cCsTtit|ttttf}ti	do|t
f7}nti|dS(Ntnetwork(Rtrun_doctestRtverboseRRvRR.R"tis_resource_enabledR8trun_unittest(RRR"((Rt	test_mainxs
t__main__RR(tunittestttestRR
RR9RRbRztTestCaseRR)R2R#R5R8RARIRNRuRvRRR.R8R1RUR'Rm(RR8RWR5RvR8RIRARRURNRbRR2RzRRuRRR9R.R)R
((Rt?s.	
		"	*	~	(



Anon7 - 2021