python (3.12.0)

(root)/
lib/
python3.12/
test/
__pycache__/
test_httpservers.cpython-312.pyc

ΑedZddlmZddlmZmZmZmZddlm	Z	m
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlmZddl Z ddl!m"Z"m#Z#ddlZddl$m%Z%dd	l&m'Z'dd
l&m(Z(e%jRdGd
dZ*GddejVZ,GddejZZ.Gdde.Z/Gdde.Z0Gdde.Z1dZ2dZ3dZ4dZ5ejle7edxrejpdk(dGdd e.Z9Gd!d"eZ:Gd#d$e:Z;Gd%d&Z<Gd'd(ejZZ=Gd)d*ejZZ>Gd+d,ejZZ?Gd-d.ejZZ@d/ZAeBd0k(rejyy)1zUnittests for the various HTTPServer modules.

Written by Cody A.W. Somerville <cody-somerville@ubuntu.com>,
Josip Dzolonga, and Michael Otteneder for the 2007/08 GHOP contest.
)OrderedDict)BaseHTTPRequestHandler
HTTPServerSimpleHTTPRequestHandlerCGIHTTPRequestHandler)server
HTTPStatusN)mock)BytesIOStringIO)support)	os_helper)threading_helperT)moduleceZdZdZddZy)NoLogRequestHandlercyN)selfargss  I/BuggyBox/python/3.12.0/bootstrap/lib/python3.12/test/test_httpservers.pylog_messagezNoLogRequestHandler.log_message(sNcyNr)rns  rreadzNoLogRequestHandler.read,srr)__name__
__module____qualname__rrrrrrr's
rrceZdZdZdZdZy)TestServerThreadc^tjj|||_||_yr)	threadingThread__init__request_handlertest_object)rr*r)s   rr(zTestServerThread.__init__1s&!!$'.&rctd|j|_|jjj	\|j
_|j
_|j
jjd|_	|jjd|jjy#|jjwxYw)N)	localhostrg?)rr)rsocketgetsocknamer*HOSTPORTserver_startedset
serve_foreverserver_closers rrunzTestServerThread.run6s !143G3GH7;{{7I7I7U7U7W4t//4''++-	'KK%%d+KK$$&DKK$$&s
CCcX|jj|jyr)rshutdownjoinr5s rstopzTestServerThread.stop@s		rN)r r!r"r(r6r:rrrr$r$0s'
'rr$c&eZdZdZdZddifdZy)BaseTestCasec@tj|_tjt
_tj|_	t||j|_|jj|jjyr)rthreading_setup_threadsrEnvironmentVarGuardosenvironr&Eventr1r$r)threadstartwaitr5s rsetUpzBaseTestCase.setUpFsg(88:
224
'oo/&tT-A-AB  "rc|jjd|_tjj	tj|jyr)rDr:rArB__exit__rthreading_cleanupr?r5s rtearDownzBaseTestCase.tearDownNs;


**DMM:rGETNctjj|j|j|_|j
j
|||||j
jSr)httpclientHTTPConnectionr/r0
connectionrequestgetresponse)rurimethodbodyheaderss     rrRzBaseTestCase.requestTsM++44TYY		JT7;**,,r)r r!r"rGrKrRrrrr<r<Es#;#(dB-rr<ceZdZGddeeZdZdZdZdZ	dZ
dZd	Zd
Z
dZdZd
ZdZdZdZdZdZdZdZdZdZdZdZdZy)BaseHTTPServerTestCasecJeZdZdZdZdZdZdZdZdZ	dZ
dZd	Zd
Z
y)&BaseHTTPServerTestCase.request_handlerHTTP/1.1c|jtj|jdd|jdd|j	y)NContent-Type	text/html
Connectionclose
send_responser	
NO_CONTENTsend_headerend_headersr5s rdo_TESTz.BaseHTTPServerTestCase.request_handler.do_TEST_sBz445^[9\73rc|jtj|jdd|jdd|j	y)Nr^r_r`
keep-aliverbr5s rdo_KEEPz.BaseHTTPServerTestCase.request_handler.do_KEEPesBz445^[9\<8rc&|jdy)N
send_errorr5s rdo_KEYERRORz2BaseHTTPServerTestCase.request_handler.do_KEYERRORksOOC rcB|jtjyrrnr		NOT_FOUNDr5s rdo_NOTFOUNDz2BaseHTTPServerTestCase.request_handler.do_NOTFOUNDnsOOJ001rc*|jdddy)Nrlz
Short MessagezThis is a long 
 explanationrmr5s rdo_EXPLAINERRORz6BaseHTTPServerTestCase.request_handler.do_EXPLAINERRORqsOOC;
=rc|jd|jdd|jdd|jy)Nrlr^r_r`ra)rcrerfr5s r	do_CUSTOMz0BaseHTTPServerTestCase.request_handler.do_CUSTOMus<s#^[9\73rc|jd|jdd|jdd|j|jdj	d}|j
j
|y)Nrl	X-SpecialDängerous Mindr`razx-special-incomingutf-8)rcrerfrWencodewfilewrite)rrVs  rdo_LATINONEHEADERz8BaseHTTPServerTestCase.request_handler.do_LATINONEHEADER{sis#[*;<\73<< 45<<WEDJJT"rcR|jt|jddyNrnintpathr5s r
do_SEND_ERRORz4BaseHTTPServerTestCase.request_handler.do_SEND_ERROROOC		!"
./rcR|jt|jddyrrr5s rdo_HEADz.BaseHTTPServerTestCase.request_handler.do_HEADrrN)r r!r"protocol_versiondefault_request_versionrgrjrorsrurwrrrrrrr)r[[s;%",			!	2	=		#	0	0rr)ctj|tjj	|j
|j|_|jjyr)	r<rGrNrOrPr/r0conconnectr5s rrGzBaseHTTPServerTestCase.setUps@4 ;;--diiCrc|jjdd|jj}|j|jt
jy)NrL/)rrRrSassertEqualstatusr	NOT_IMPLEMENTEDrress  rtest_commandz#BaseHTTPServerTestCase.test_commandsB$hh""$Z%?%?@rcd|j_|jjdd|jj|jj	}|j|jtjy)Nz	HTTP/1.1
XYZBOGUSr	r
_http_vsn_str
putrequest
endheadersrSrrr	rrs  rtest_request_line_trimmingz1BaseHTTPServerTestCase.test_request_line_trimmings^!-J,hh""$Z%?%?@rcd|j_|jjdd|jj|jj	}|j|jtjy)NFUBARrLr	rrrrrSrrr	BAD_REQUESTrs  rtest_version_bogusz)BaseHTTPServerTestCase.test_version_boguss^!(E3'hh""$Z%;%;<rcd|j_|jjdd|jj|jj	}|j|jtjy)Nz
HTTP/9.9.9rLrrrs  rtest_version_digitsz*BaseHTTPServerTestCase.test_version_digitss^!-E3'hh""$Z%;%;<rcd|j_|jjdd|jj|jj	}|j|jtjy)NzHTTP/-9_9_9.+9_9_9rLrrrs  r"test_version_signs_and_underscoresz9BaseHTTPServerTestCase.test_version_signs_and_underscoress^!5E3'hh""$Z%;%;<rcd|j_|jjdd|jj|jj	}|j|jtjy)NzHTTP/909876543210.0rLrrrs  r"test_major_version_number_too_longz9BaseHTTPServerTestCase.test_major_version_number_too_long^!6E3'hh""$Z%;%;<rcd|j_|jjdd|jj|jj	}|j|jtjy)NzHTTP/1.909876543210rLrrrs  r"test_minor_version_number_too_longz9BaseHTTPServerTestCase.test_minor_version_number_too_longrrcd|j_|jjdd|jj|jj	}|j|jtjy)NrrLrrrs  rtest_version_none_getz,BaseHTTPServerTestCase.test_version_none_gets^!#E3'hh""$Z%?%?@rcd|j_|jjdd|jj|jj	}|j|jtjy)NrCUSTOMrrrs  rtest_version_nonez(BaseHTTPServerTestCase.test_version_nones^!#Hc*hh""$Z%;%;<rc<d|j_d|j_|jjdd|jj	|jj}|j
|jtjy)NczHTTP/9.9rLr)
r	_http_vsnrrrrSrrr	HTTP_VERSION_NOT_SUPPORTEDrs  rtest_version_invalidz+BaseHTTPServerTestCase.test_version_invalidsj!+E3'hh""$Z%J%JKrcd|j_|jjdd|jj|jj	}|j|jtjyrrrs  rtest_send_blankz&BaseHTTPServerTestCase.test_send_blanks^!#B#hh""$Z%;%;<rc0|jjdd|jjdd|jj|jj	}|j|jtjy)NrLrr`ra)	rr	putheaderrrSrrr	rrs  rtest_header_closez(BaseHTTPServerTestCase.test_header_closesfE3'<1hh""$Z%?%?@rcRd|j_|jjdd|jjdd|jj	|jj}|j
|jtjy)Nr\rLrr`ri)
rrrrrrSrrr	rrs  rtest_header_keep_alivez-BaseHTTPServerTestCase.test_header_keep_alivesr!+E3'<6hh""$Z%?%?@rc|jjdd|jj}|j|jt
jy)NTESTr)rrRrSrrr	rdrs  rtest_handlerz#BaseHTTPServerTestCase.test_handlersB%hh""$Z%:%:;rc4|jjdd|jj}|j|j	dd|jjdd|j|jjy)NKEEPrr`rir)rrRrSr	getheader
addCleanuprars  rtest_return_header_keep_alivez4BaseHTTPServerTestCase.test_return_header_keep_alivesi%hh""$|4lC%'rc|jjdd|jj}|j|jdy)NKEYERRORrrlrrRrSrrrs  rtest_internal_key_errorz.BaseHTTPServerTestCase.test_internal_key_errors<S)hh""$S)rc|jjdd|jj}|j|jdy)Nrrrlrrs  rtest_return_custom_statusz0BaseHTTPServerTestCase.test_return_custom_statuss<3'hh""$S)rc|jjdd|jj}|j|jd|jt
|jdy)NEXPLAINERRORrrlContent-Length)rrRrSrr
assertTruerrrs  rtest_return_explain_errorz0BaseHTTPServerTestCase.test_return_explain_errorsW-hh""$S)CMM*:;<=rc|jjddddi|jj}|j|j	dd|j|jdj
dy)	NLATINONEHEADERrzX-Special-IncominguÄrger mit UnicoderWryrzr{)rrRrSrrrr|rs  rtest_latin1_headerz)BaseHTTPServerTestCase.test_latin1_headersw)3 (<9
	hh""${35FG%9%@%@%IJrcJ|jjdd|jj}|j|jt
j|j}|jt|jdt|y)NNOTFOUNDrr)rrRrSrrr	rrrrrlen)rrdatas   rtest_error_content_lengthz0BaseHTTPServerTestCase.test_error_content_lengthspS)hh""$Z%9%9:xxzS]]+;<=s4yIrctjtjf}tjtjtjtjtj
fD]}|jjddj||jj}|j||j|jd|jd|jd|jd||vr!|jd|jd|j}|jd|y)N
SEND_ERROR/{}rr^Transfer-Encodingr)r	NOT_MODIFIED
RESET_CONTENTrd
PROCESSINGSWITCHING_PROTOCOLSrrRformatrSrrrrrallow_transfer_encoding_codescoderrs     rtest_send_errorz&BaseHTTPServerTestCase.test_send_errors)3)@)@)3)A)A)C%**J,C,C**J,D,D335	(D
HH\5<<+=>((&&(CT3::.T3==1A#BCT3==#@A88  s}}5H'IJ88:DS$'	(rctjtjf}tjtjtjtjtj
fD]N}|jjddj||jj}|j||j|tjk(rN|jt|jddkD|jd|jdnB|jd|jd|jd|jd||vr!|jd|jd|j!}|jd|Qy)	NHEADrrrr_r^rr)r	rrOKrdrrrRrrSrrrrrassertInrrs     rtest_head_via_send_errorz/BaseHTTPServerTestCase.test_head_via_send_error(sP)3)@)@)3)A)A)C%]]J$9$9,,j.F.F335	(D
HHVU\\$%78((&&(CT3::.z}}$CMM2B$C Dq HI

k3==+HI  s}}5E'FG  s}}^'DE88  s}}5H'IJ88:DS$'!	(rN)r r!r"rrr)rGrrrrrrrrrrrrrrrrrrrrrrrrrrYrYZs,0-/E,0\
A
A=====A=L=AA<
(*
*
>KJ("(rrYc.eZdZGddeZdZdZy)RequestHandlerLoggingTestCasec eZdZdZdZdZdZy)-RequestHandlerLoggingTestCase.request_handlerr\cb|jtj|jyr)rcr	rrfr5s rdo_GETz4RequestHandlerLoggingTestCase.request_handler.do_GETCs z}}-rcD|jtjdy)NzFile not foundrqr5s rdo_ERRORz6RequestHandlerLoggingTestCase.request_handler.do_ERRORGsOOJ002BCrN)r r!r"rrrrrrrr)r?s%",		Drr)ctjj|j|j|_|j
j
tj5}|j
jdd|j
jddd|jjjdy#1swY8xYw)NrLrz"GET / HTTP/1.1" 200 -
)rNrOrPr/r0rrr
captured_stderrrRrSrgetvalueendswith)rerrs  rtest_getz&RequestHandlerLoggingTestCase.test_getJs;;--diiC

$
$
&	##HHUC(HH  "	#	
LLN##$>?	A		#	#s(7CCc2tjj|j|j|_|j
j
tj5}|j
jdd|j
jdddjjd}|j|djd|j|djdy#1swYoxYw)NERRORr
rz code 404, message File not foundrz"ERROR / HTTP/1.1" 404 -)rNrOrPr/r0rrr
rrRrSrsplitrr)rrliness   rtest_errz&RequestHandlerLoggingTestCase.test_errUs;;--diiC

$
$
&	##HHWc*HH  "	#$$T*a))*LMNa))*DEF
	#	#s(7D

DN)r r!r"rr)rrrrrrr>s	D0	D	A
Grrc\eZdZGddeeZfdZfdZddZe	jejdk(de	jejdk(d	e	jejd
dZdZd
ZdZdZdZdZdZdZdZdZdZxZS)SimpleHTTPServerTestCaseceZdZy)(SimpleHTTPServerTestCase.request_handlerN)r r!r"rrrr)rcsrr)ct|tj|_tj}tj|d|_tj||_
tjj|j|_
d|jz|_tjj|jd}t!|d5}|j#|j|j%dddtj&|j(}t*j*j-|t*j.j0}|j3d|_t6j8j;|j=d	|_y#1swYxYw)
NsWe are the knights who say Ni!)dirrtestwbr)microsecondTusegmt) superrGrAgetcwdcwdtempfile
gettempdirchdirrmkdtemptempdirrbasenametempdir_namebase_urlr9openr~flushstatst_mtimedatetime
fromtimestamptimezoneutcreplacelast_modif_datetimeemailutils
formatdate	timestamplast_modif_header)rbasetempdirtempnametempmtime
last_modif	__class__s      rrGzSimpleHTTPServerTestCase.setUpfsH

99;))+
5	''K8GG,,T\\:d///
77<<f5
(D
!	TJJtyy!JJL	!**&&44U!!#
#-#5#5!#5#D !&!7!7  "4"8"1		s,,GGc	tj|j	tj|j
t|y#YxYw#t|wxYwr)rArrshutilrmtreerr
rKrr)s rrKz!SimpleHTTPServerTestCase.tearDown{sP	HHTXX


dll+
G
GsAAAAA(cfd}d|_j}|j|jj||jj|r|j|||jjd|jjjddd|jjdddj|S)Nc,jd_y)zWDon't close reader yet so we can check if there was leftover
            buffered inputN)fp)readerresponsesr
close_connzDSimpleHTTPServerTestCase.check_status_and_reason.<locals>.close_conns[[FHKr
r`rarzConnection should be closed)_close_connrrrrassertIsNotNonereasonversionmsggetra)rr2rrr3rVr1s `    @rcheck_status_and_reasonz0SimpleHTTPServerTestCase.check_status_and_reasons	)}}!&1X__-T4(	
))2.)),@'JR#/LMrdarwinz2undecodable name cannot always be decoded on macOSwin32z+undecodable name cannot be decoded on win32z!need os_helper.TESTFN_UNDECODABLEctj}tjtj
dz}t
tjj|j|d5}|jtj
ddd|j|jdz}tjdk(r-tj|jD]}|dk7s	|}n|j|t j"}t$j&j)|d}|j+d|zj-|d	||j+d
t/j0|dzj-|d	||j|jdz|z}|j|t j"tj

y#1swYZxYw)Nz.txtrrr=r
surrogatepass)errorsz	href="%s"surrogateescape>%s<Fquoter)sysgetfilesystemencodingrAfsdecoderTESTFN_UNDECODABLErrr9rr~rRrplatformlistdirr<r	rurllibparserErr|htmlescape)rencfilenamefr2namerV
quotednames        rtest_undecodable_filenamez2SimpleHTTPServerTestCase.test_undecodable_filenames'');;y;;<vE
"'',,t||X6
=	2
GGI001	2<<

 34<<8#

4<<0
6>#H
++HjmmD\\'''I


{Z/vc#45t	=

vHE BBvc#45t	=<<

 3j @A$$Xz}}*3*F*F	%	H#	2	2s/ G''G1cp|j|jdzj}|j|d|jdj	d|j|jdzj}|j|d|jdj	dy)Nz/?x=123zlisting for z/\?x=123latin1z/?x=%bbz/\?x=\xef\xbf\xbd)rRrrassertRegexr|rr2s  rtest_undecodable_parameterz3SimpleHTTPServerTestCase.test_undecodable_parameters<<

	 9:??Al4==/#J#Q#QRZ#[\<<

	 9:??Al4==/AR#S#Z#Z[c#derctjtjj|jdd|j
d}|d}|j
|}|j|tj|jd}|j||dd|}|j
|}|j|tj|jd}|j|jd||j||d	d|}|j
|}|j|tj|j|jd|d
|}|d}|j
|}|j|tj|jd}|j|jd
|y)aIEnsure //evil.co/..%2f../../X does not put //evil.co/ in Location.

        //netloc/ in a Location header is a redirect to a new host.
        https://github.com/python/cpython/issues/87389

        This checks that a path resolving to a directory on our server cannot
        resolve into a redirect to another server.
        existing_directoryz2/python.org/..%2f..%2f..%2f..%2f..%2f../%0a%0d/../z/existing_directoryrLocationznon-attack failed!r://zcExpected Location header to start with a single / and end with a / as this is a directory redirect.zhttps://pypi.org/N)rAmkdirrr9rrrRr<r	MOVED_PERMANENTLYrrassertFalse
startswithr)	rurlexpected_locationr2location
attack_urlattack3_urlattack_scheme_netloc_2slash_urlexpected_scheme_netloc_locations	         r3test_get_dir_redirect_location_domain_injection_bugzLSimpleHTTPServerTestCase.test_get_dir_redirect_location_domain_injection_bugs	dll,@ABB4CTCTBUUhi"e1I<<$$$Xz/K/KL%%j1#4:NOY
<<
+$$Xz/K/KL%%j1,,T2A#4@		A
3%j<<,$$Xz/K/KL++J79JK->cU*C'-L,MQ*O'<< ?@$$Xz/K/KL%%j1	
++,?@hOrc.|j|jdz}|j|tj|j
|j|jdz}|j|tj|j|jdz}|j|tj|j|j}|j|tj|j|jdd|j|jdz}|j|tj|j|jdz}|j|tj|j|jd	|jd
z|jd}|j|tj|jd}|j|tjtjtjj|jd
d|j|jdz}|j|tjd}ttjj|j dd5}|j#|ddd|j|jdz}|j|tj|tj$dk(rtj&dk7rtj(|jd	|j|jdz}|j|tjtj(|jdyyy#1swYxYw#tj(|jdwxYw)N/testrF/test/rr0/?hi=2?hi=1r^/?hi=1z/ThisDoesNotExistz/ThisDoesNotExist/spamz
index.htmlz/spam/sDummy index file
rposixri)rRrr<r	rrrrrbrrrAmakedirsrr9rrrr~rTgeteuidchmod)rr2rrSs    rrz!SimpleHTTPServerTestCase.test_gets<<

 78$$Xz}}499$M<<

 89$$Xz/C/CD<<

 34$$Xz}}=<<

.$$Xz/K/KL++,<=sC<<

 89$$Xz}}=<<

 78$$Xz/K/KL++J71	3<< 34$$Xz/C/CD<< >?$$Xz/C/CD
BGGLLv|DE<<

 89$$Xz}}=&
"'',,t00,?
F	!
GGDM	<<

 34$$Xz}}dC77g"**,!"3HHT\\1%
.<<

(;<,,Xz7K7KLu-
#4		u-s!O&>O2&O/2"Pc@|j|jdzd}|j|tj|j|j
dtt|j|j|j
ddy)NrnrrUzcontent-lengthzcontent-typezapplication/octet-stream)
rRrr<r	rrrstrrrrZs  r	test_headz"SimpleHTTPServerTestCase.test_heads<<MMG#F 4$$Xz}}=++,<=S^,	.++N;3	5rc(tjj}|j|d<|j	|j
dz|}|j
|tj|jtjdz}tjj}tjj|d|d<|j	|j
dz|}|j
|tjy)	zCheck that when a request to /test is sent with the request header
        If-Modified-Since set to date of last modification, the server returns
        status code 304, not 200
        If-Modified-Sincernrr)hoursTrN)rmessageMessager#rRrr<r	rrr	timedeltar format_datetime)rrWr2new_dts    rtest_browser_cachez+SimpleHTTPServerTestCase.test_browser_cache's
--'')'+'='=#$<<

 7<I$$Xz/F/FG))H,>,>Q,GG--'')',{{'B'B6(C(#$<<

 7<I$$Xz/F/FGrcR|j}|tjdz
}tjj}tjj|d|d<|j|jdz|}|j|tjy)Nim)daysTrr~rnr)
rrrrrrr rrRrr<r	r)rdtold_dtrWr2s     rtest_browser_cache_file_changedz8SimpleHTTPServerTestCase.test_browser_cache_file_changed9s

%
%h((c22--'')',{{'B'B6(C(#$<<

 7<I$$Xz}}=rctjj}|j|d<d|d<|j	|j
dz|}|j
|tjy)Nr~*z
If-None-Matchrnr)	rrrr#rRrr<r	r)rrWr2s   r,test_browser_cache_with_If_None_Match_headerzESimpleHTTPServerTestCase.test_browser_cache_with_If_None_Match_headerDs`--'')'+'='=#$#& <<

 7<I$$Xz}}=rc6|jdd}|j|tj|jdd}|j|tj|jdd}|j|tjy)NrFOOrzcustomGETs)rRr<r	rrZs  rtest_invalid_requestsz.SimpleHTTPServerTestCase.test_invalid_requestsMsz<<E<2$$Xz/I/IJ<<H<5$$Xz/I/IJ<<F<3$$Xz/I/IJrc|j|jdz}|j|tj|j
|jd}|j||jy)zChecks that the datetime returned in Last-Modified response header
        is the actual datetime of last modification, rounded to the second
        rnrFz
Last-modifiedN)	rRrr<r	rrrWrr#)rr2r#s   rtest_last_modifiedz+SimpleHTTPServerTestCase.test_last_modifiedVs`<<

 78$$Xz}}499$M$,,_=*D,B,BCrcZ|j|jdz}|j|tj|j
|j|jdz}|j|tj|j|jdz}|j|tj|j|j}|j|tj|j|jdz}|j|tj|j|jdz}|j|tj|j|jd|jdzy)	NrnrFrorrqrrr^rs)
rRrr<r	rrrrrbrrrZs  rtest_path_without_leading_slashz8SimpleHTTPServerTestCase.test_path_without_leading_slash_sC<< 1 1G ;<$$Xz}}499$M<< 1 1H <=$$Xz/C/CD<< 1 1C 78$$Xz}}=<< 1 12$$Xz/K/KL<< 1 1H <=$$Xz}}=<< 1 1G ;<$$Xz/K/KL++J7**X5	7rcd}tjj|j|}	t	|dj	|j|jdz}|j|tj}|jj}tj ||j#|dt%j&|dz}|j)|j+||y#t$rtjd|zwxYw#tj |wxYw)Nz<test&>.txtrz-Can not create file %s on current file systemrrCFrD)rArr9rrraOSErrorunittestSkipTestrRrr<r	rrWget_content_charsetunlinkr7rOrPrr|)rrRfullpathr2rVrQ	html_texts       rtest_html_escape_filenamez2SimpleHTTPServerTestCase.test_html_escape_filenameos 77<<h7	94 &&(
	 ||DMMC$78H//*--HD""668CIIhS!T[[??	

i&&s+T2	9##%-/7%89
9	9
IIhsD	AD("D%(D?r)r r!r"rrr)rGrKr<rskipIfrGrK
skipUnlessrrJrVr[rlrr|rrrrrrr
__classcell__r)s@rrrbs
-/G
1*2X__S\\X-IKX__S\\W,BDX55<>H>DKH.f/Pb(.T5H$	>>KD7 3rrzD#!%s

print("Content-type: text/html")
print()
print("Hello World")
a#!%s
import os
import sys
import urllib.parse

print("Content-type: text/html")
print()

content_length = int(os.environ["CONTENT_LENGTH"])
query_string = sys.stdin.buffer.read(content_length)
params = {key.decode("utf-8"): val.decode("utf-8")
            for key, val in urllib.parse.parse_qsl(query_string)}

print("%%s, %%s, %%s" %% (params["spam"], params["eggs"], params["bacon"]))
zR#!%s
import os

print("Content-type: text/html")
print()

print(os.environ["%s"])
a'#!%s
import os

print("X-ambv: was here")
print("Content-type: text/html")
print()
print("<pre>")
for k, v in os.environ.items():
    try:
        k.encode('ascii')
        v.encode('ascii')
    except UnicodeEncodeError:
        continue  # see: BPO-44647
    print(f"{k}={v}")
print("</pre>")
rwz7This test can't be run reliably as root (issue #13308).ceZdZGddeeZejjdZdZ	dZ
dZdZdZ
d	Zd
ZdZdZd
ZdZdZdZdZdZdZy)CGIHTTPServerTestCaseceZdZfdZxZS)%CGIHTTPServerTestCase.request_handlerctjdt5t|cdddS#1swYyxYw)Nignore)actioncategory)warningscatch_warningsDeprecationWarningr
run_cgir-s rrz-CGIHTTPServerTestCase.request_handler.run_cgis5((CUV
)w(
)
)
)s5>)r r!r"rrrs@rr)rs
	)	)rr)asciictj|tj|_tj|_tjj|jd|_
tjj|jd|_tjj|jd|_tjj|jd|_
tjj|jd|_tj|jtj|jtj|jtj|jtj|jd|_d|_d|_d|_d|_d|_d|_t/j0rbtjj|jd|_t5j6|j2j9|_nt:j<|_	|j2j?dtjj|jd|_tG|j d	d
5}|jItJ|j2zdddtjL|j dtjj|jd|_tG|j"d	d
5}|jItJ|j2zdddtjL|j"dtjj|jd
|_tG|j$d	d
5}|jItN|j2zdddtjL|j$dtjj|jd|_tG|j&d	d
5}|jItJ|j2zdddtjL|j&dtjj|jd|_tG|j(d	d
5}|jItP|j2dfzdddtjL|j(dtjj|jd|_tG|j*d	d
5}|jItJ|j2zdddtjL|j*dtjj|jd|_)tG|jRd	d
5}|jItT|j2zdddtjL|jRdtjV|jy#t@$r%|jC|jEdYMwxYw#1swYxYw#1swYdxYw#1swYxYw#1swYZxYw#1swYxYw#1swYNxYw#1swYxYw)Nzcgi-binz	child-dirsubrpythonr{z0Python executable path is not encodable to utf-8znocgi.pyw)encodingizfile1.pyzfile2.pyzfile3.pyzfile4.pyQUERY_STRINGzfile5.pyzfile6.py),r<rGrArrr
r
parent_dirrr9cgi_dir
cgi_child_dir	sub_dir_1	sub_dir_2cgi_dir_in_sub_dirra
nocgi_path
file1_path
file2_path
file3_path
file4_path
file5_path_pythonexe_symlinkrcan_symlink	pythonexer

PythonSymlink	__enter__rG
executabler|UnicodeEncodeErrorrKskipTestrr~	cgi_file1rx	cgi_file2	cgi_file4
file6_path	cgi_file6r)rr0file1file2file3file4file5file6s        rrGzCGIHTTPServerTestCase.setUps4 99;"**,ww||DOOY?WW\\$,,Ddoou=dnne<"$'',,t~~y"I

##$
 
 
(()#'  "WW\\$//8DDN&-&;&;DNN&K&U&U&WD# ^^DN	N
NN!!'*
'',,t
C
$//3
9	1RHHY/0	1
%('',,t||Z@
$//3
9	4UKK	DNN23	4
%('',,t||Z@
$//3
9	4UKK	DNN23	4
%('',,t'9'9:F
$//3
9	4UKK	DNN23	4
%('',,t||Z@
$//3
9	FUKK	T^^^$DDE	F
%('',,t'>'>
K
$//3
9	4UKK	DNN23	4
%('',,t||Z@
$//3
9	4UKK	DNN23	4
%(
!O"	NMMOMMLM	N
	1	1
	4	4
	4	4
	4	4
	F	F
	4	4
	4	4sf[-#[7?#\#\##\5%\+	#\8#]*[43[47\\\\(+\58]]c	tj|j|jr|jj	ddd|j
rtj|j
|jrtj|j|jrtj|j|jrtj|j|jrtj|j|jrtj|j|jrtj|jtj|jtj|jtj|j tj|j"tj|j$tj|j&t(j+|y#t(j+|wxYwr)rArrrrIrremoverrrrrrrmdirrrrrrrr<rKr5s rrKzCGIHTTPServerTestCase.tearDownsZ	(HHTXX&&''00tTB		$//*		$//*		$//*		$//*		$//*		$//*		$//*HHT''(HHT\\"HHT,,-HHT^^$HHT^^$HHT__%!!$'L!!$'sH/IIc
idddtdtddddddddd	d
d
d
ddd
ddddddddddddddddddtddtddd}|jD]y\}}t|tr2t	|t
r"|j
|tj|Htj|}|j||d|d|d|{y)Nrr`z..z/.//..rz/\z//\z/.//cgi-bin/file1.py/cgi-bin/file1.pyaz//az/az./az./C:/z/C:/z/a/bz/a/b/z/a/b/.z/a/b/dz/a/b/d/fz/a/b/fz/a/fz//f)z	/a/b/c/..z/a/b/c/../dz/a/b/c/../d/e/../fz/a/b/c/../d/e/../../fz/a/b/c/../d/e/.././././..//fz../a/b/c/../d/e/.././././..//fz/a/b/c/../d/e/../../../fz/a/b/c/../d/e/../../../../fz/a/b/c/../d/e/../../../../../fz/a/b/c/../d/e/../../../../f/..z /a/b/c/../d/e/../../../../f/../.zpath = z	
Got:    z	
Wanted: r_)

IndexErroritems
isinstancetype
issubclass	ExceptionassertRaisesr_url_collapse_pathr)rtest_vectorsrexpectedactuals     rtest_url_collapse_pathz,CGIHTTPServerTestCase.test_url_collapse_path/s}

*

j

	


$

6


D

 3

 !4



%

5

5

V

F
 
W!
"
g#
$!#",%-,4.8(.+0.8.2049
<+002	;ND((D)j9.M!!("(";";TC 2248  6"&&:!;
	;rc|jd}|j|j|jd|jfd|j
zdtjfy)NrContent-typeHello Worldr_)rRrrrrlinesepr	rrs  rtest_headers_and_contentz.CGIHTTPServerTestCase.test_headers_and_contentYsTll./
XXZ~6

C
dll
*KG	Ircz|jd}|j|jtjy)Nz)///////////nocgi.py/../cgi-bin/nothere.sh)rRrrr	rrrs  rtest_issue19435z%CGIHTTPServerTestCase.test_issue19435_s+llFGZ%9%9:rctjjdddd}ddi}|jdd||}|j	|jd	|jzy)
Nrri@)rteggsbaconrz!application/x-www-form-urlencodedz/cgi-bin/file2.pyPOSTs1, python, 123456)rMrN	urlencoderRrrr)rparamsrWrs    r	test_postzCGIHTTPServerTestCase.test_postcs`''(f=?!$GHll.H%9DLL%HIrc|jd}|j|j|jtj
y)Nz/cgi-bin/invalid)rRrrrr	rrrs  rtest_invaliduriz%CGIHTTPServerTestCase.test_invaliduriks4ll-.
Z%9%9:rcddtjdzi}|jdd|}|jd|jzdt
jf|j|jd	|jfy)
Ns
AuthorizationsBasic s
username:passrrLrrr_r)
base64	b64encoderRrrr	rrrr)rrWrs   rtest_authorizationz(CGIHTTPServerTestCase.test_authorizationpsz#i##$45'67ll.wlG
dll
*KG
XXZ~6

C	Erc|jd}|jd|jzdtjf|j|j
d|jfy)Nrrr_rrRrrr	rrrrrs  rtest_no_leading_slashz+CGIHTTPServerTestCase.test_no_leading_slashxsTll-.
dll
*KG
XXZ~6

C	ErcJd}|tjd<|jd}|jd|jzdt
jf|j|jd|jf|jtjd|y)NzTest CGI ServerSERVER_SOFTWARErrr_r)
rArBrRrrr	rrrr)r	signaturers   rtest_os_environ_is_not_alteredz4CGIHTTPServerTestCase.test_os_environ_is_not_altereds%	(1

$%ll./
dll
*KG
XXZ~6

C	E	
$56	Brc|jd}|jd|jzdtjf|j|j
d|jfy)Nz/cgi-bin%2ffile1.pyrr_rrrs  r#test_urlquote_decoding_in_cgi_checkz9CGIHTTPServerTestCase.test_urlquote_decoding_in_cgi_checksTll01
dll
*KG
XXZ~6

C	Erc|jd}|jd|jzdtjf|j|j
d|jfy)Nz/cgi-bin/child-dir/file3.pyrr_rrrs  rtest_nested_cgi_path_issue21323z5CGIHTTPServerTestCase.test_nested_cgi_path_issue21323sTll89
dll
*KG
XXZ~6

C	Erc|jd}|jd|jzdtjf|j|j
d|jfy)Nz/cgi-bin/file4.py?a=b?c=dsa=b?c=dr_rrrs  r&test_query_with_multiple_question_markz<CGIHTTPServerTestCase.test_query_with_multiple_question_marksTll67
$,,
&Z]]C
XXZ~6

C	Erc|jd}|jd|jzdtjf|j|j
d|jfy)Nz0/cgi-bin/file4.py?k=aa%2F%2Fbb&//q//p//=//a//b//sk=aa%2F%2Fbb&//q//p//=//a//b//r_rrrs  r"test_query_with_continuous_slashesz8CGIHTTPServerTestCase.test_query_with_continuous_slashessWllMN
.
=
*--
)
XXZ~6

C	Erc	tjjd|jd}|j	d|j
zdtjf|j|jd|jftjjdy#tjjdwxYw)Nz/sub/dir/cgi-binz/sub/dir/cgi-bin/file5.pyrr_r)rcgi_directoriesappendrRrrr	rrrrrrs  r test_cgi_path_in_sub_directoriesz6CGIHTTPServerTestCase.test_cgi_path_in_sub_directoriess	M!11889KL,,:;C$,,.Z]]KS]]>:CJJG
I
"11889KL!11889KLsB
B,,!C
cd}d|ff|fddf}|D]\}}t|}|j|5|jdd|}|jtj
j|jd|jd	}|j||jdddy#1swYxYw)
Nz?text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept)rr)))rr_)ACCEPTz
text/plainztext/html,text/plainz/cgi-bin/file6.pyrLrzHTTP_ACCEPT=r)rsubTestrRrrNr	rrr|rr)rbrowser_accepttestsrWrrs      rtest_acceptz!CGIHTTPServerTestCase.test_acceptsU	(
*N;
'	
"'	4GX!'*Gg&
4ll#6wlO  !3!3SZZ@)(4;;GD

h
3	
4
4	4
4
4sA=B99C	N)r r!r"rrr)rArr|rGrKrrrrrrrrrrr	rrrrrrrrs)-/D)jj(GJ"X(8(;TI;J;
EECEEEEM4rrc,eZdZdfd	ZdZdZxZS)SocketlessRequestHandlerctj}t|j_t
||dd|d|_d|_y)N	directoryFr\)	r
Mockrmakefilereturn_valuer
r(
get_calledr)rrrRr)s   rr(z!SocketlessRequestHandler.__init__sC))+(/	%
$	B *rcd|_|jtj|j	dd|j|jjdy)NTr^r_ <html><body>Data</body></html>
)rrcr	rrerfr}r~r5s rrzSocketlessRequestHandler.do_GETsJ:==)5

>?rcyrr)rrrs   rrz$SocketlessRequestHandler.log_messagesrr)r r!r"r(rrrrs@rrrs+@
rrceZdZdZy)!RejectingSocketlessRequestHandlercB|jtjy)NF)rnr	EXPECTATION_FAILEDr5s rhandle_expect_100z3RejectingSocketlessRequestHandler.handle_expect_100s
556rN)r r!r"r'rrrr$r$srr$c.eZdZdZdZdZedZy)AuditableBytesIOcg|_yr)datasr5s rr(zAuditableBytesIO.__init__s	
rc:|jj|yr)r+r)rrs  rr~zAuditableBytesIO.writes

$rc8dj|jS)Nr)r9r+r5s rgetDatazAuditableBytesIO.getDatasxx

##rc,t|jSr)rr+r5s r	numWriteszAuditableBytesIO.numWritess4::rN)r r!r"r(r~r.propertyr0rrrr)r)s% $rr)ceZdZdZej
dZdZdZdZ	dZ
dZdZd	Z
d
ZdZdZd
ZdZdZdZdZdZdZdZdZdZdZdZdZy)BaseHTTPRequestHandlerTestCasezrTest the functionality of the BaseHTTPServer.

       Test the support for the Expect 100-continue header.
       sHTTP/1.[0-9]+ 200 OKc"t|_yr)rhandlerr5s rrGz$BaseHTTPRequestHandlerTestCase.setUps/1rct|}t}||j_||j_|jj	|jd|j
SNr)rr5rfiler}handle_one_requestseek	readlines)rrinputoutputs    rsend_typical_requestz3BaseHTTPRequestHandlerTestCase.send_typical_requestsU "#'')A!!rcN|j|jjyr)rr5rr5s rverify_get_calledz0BaseHTTPRequestHandlerTestCase.verify_get_calleds//0rc\dD]&|jtfd|Dd(y)N)sServer: sDate: sContent-Type: c3@K|]}|jywr)rd).0h	fieldNames  r	<genexpr>zIBaseHTTPRequestHandlerTestCase.verify_expected_headers.<locals>.<genexpr>s JQi!8 Jsr)rsum)rrWrEs  @rverify_expected_headersz6BaseHTTPRequestHandlerTestCase.verify_expected_headerss/B	OIS J' JJAN	Orc\|jj|}|j|yr)HTTPResponseMatchsearchr7)rr2matchs   rverify_http_server_responsez:BaseHTTPRequestHandlerTestCase.verify_http_server_responses&&&--h7U#rcd|j_tj}tj
j
tdt5}||jd||jd||jdd||jdd||jddddj}|jd	||jd
||j}|jd|d|jd|d
|jd|d|jd|d|jd|dy#1swYxYw)N)	127.0.0.1i9stderrz/fooz/barz	/spam %s.ruŸ beansz"GET /foo\b"ar HTTP/1.0"rz/\x1bbar\x00\x1brz/spam a.u/spam \x1b\x7f\x9f beans.z"GET /foo\\b"ar\x07 HTTP/1.0")
r5client_addressrrr
patchobjectrGrrassertNotIn
splitlinesr)rrfake_stderrrPrs     rtest_unprintable_not_loggedz:BaseHTTPRequestHandlerTestCase.test_unprintable_not_loggeds6':#,88
ZZ

sHhj
9	G[f-&89k37k3JK&EF	G%%'((!!#

feAh'

)584

j%(+

7qB

6aA	G	Gs
A"E''E0cX|jd}|j|d|j|dd|j|j	|dd|j	|j
jd|j	|j
jd|j	|j
jd|j	|j
jd	|j|j
jjd
y)NGET / HTTP/1.1

rrr!GET / HTTP/1.1rLrr\r
r>rMrHr@rr5requestlinecommandrrequest_versionassertSequenceEqualrWrrresults  r
test_http_1_1z,BaseHTTPRequestHandlerTestCase.test_http_1_1**+DE((3$$VAb\2 %JK113CD--u5**C055zB  !5!5!;!;!=rBrcX|jd}|j|d|j|dd|j|j	|dd|j	|j
jd|j	|j
jd|j	|j
jd|j	|j
jd	|j|j
jjd
y)NsGET / HTTP/1.0

rrr_r!GET / HTTP/1.0rLrHTTP/1.0rrarfs  r
test_http_1_0z,BaseHTTPRequestHandlerTestCase.test_http_1_0'rirc|jd}|jt|d|j|dd|jy)NsGET / HTTP/0.9

rrr!)r>rrr@rfs  r
test_http_0_9z,BaseHTTPRequestHandlerTestCase.test_http_0_93sH**+DEVa($IJ rc|jd}|j|djd|j|d|j	d|j|jjy)Ns)GET /spaced out HTTP/1.1
Host: dummy

rs
HTTP/1.1 400 r
)r>rrdrHindexrcr5rrfs  rtest_extra_spacez/BaseHTTPRequestHandlerTestCase.test_extra_space9sk**


	
q	,,-=>?$$VAfll7.C%DE001rc\|jd}|j|d|j|dd|j|j	|dd|j	|j
jd|j	|j
jd|j	|j
jd|j	|j
jd	d
}|j|j
jj|y)Ns(GET / HTTP/1.0
Expect: 100-continue

rrr_r!rkrLrrl)Expectz100-continuerarrgrWs   rtest_with_continue_1_0z5BaseHTTPRequestHandlerTestCase.test_with_continue_1_0Cs**+\]((3$$VAb\2 %JK113CD--u5**C055zB/  !5!5!;!;!=wGrc|jd}|j|dd|j|dd|j|dd|j|dd|j|j|dd	|j|jj
d
|j|jjd|j|jjd|j|jjd
d}|j|jjj|y)N(GET / HTTP/1.1
Expect: 100-continue

rsHTTP/1.1 100 Continue
rrqrSsHTTP/1.1 200 OK
r_r!r`rLrr\ru)r>rrHr@r5rbrcrrdrerWrrws   rtest_with_continue_1_1z5BaseHTTPRequestHandlerTestCase.test_with_continue_1_1Ps**+\]$@AG,$:;$$VAb\2 %JK113CD--u5**C055zB/  !5!5!;!;!=wGrctd}t}t}||_||_d|_d|_d|_|jd|j|jdy)Nr^r\rrS)rr)rr8r}rdrbrcrnrr0rr<r=r5s    r#test_header_buffering_of_send_errorzBBaseHTTPRequestHandlerTestCase.test_header_buffering_of_send_error_sf12!#*,

", 3))1-rctd}t}t}||_||_d|_|j
d|j|jd|j|j|jdy)Nr^r\r}rr)
rr)rr8r}rdsend_response_onlyrr0rfr~s    r+test_header_buffering_of_send_response_onlyzJBaseHTTPRequestHandlerTestCase.test_header_buffering_of_send_response_onlymsy12!#*,

",""3'))1-))1-rctd}t}t}||_||_d|_|j
dd|j
dd|j|jd|j|j|jd|j|jdy)	Nr^r\FoofoobarrsFoo: foo
bar: bar

r)rr)rr8r}rdrerr0rfr.r~s    r$test_header_buffering_of_send_headerzCBaseHTTPRequestHandlerTestCase.test_header_buffering_of_send_header{s12!#*,

",E5)E5)))1-)+JK))1-rcd}td}t}||j_||j_d|j_|jj|j
||d||jd}|j|dd|j|dd|j|d	d
y)Nc|j}|jd|j}|j||Sr7)tellr:r)rSposrs   r_readAndReseekz[BaseHTTPRequestHandlerTestCase.test_header_unbuffered_when_continue.<locals>._readAndReseeks3&&(C
FF1I668D
FF3KKrrzr\rrqrsHTTP/1.1 100 ContinuerrSsHTTP/1.1 200 OK)	rr5r8r}rdr9assertNotEqualrr)rrr<r=rgs     r$test_header_unbuffered_when_continuezCBaseHTTPRequestHandlerTestCase.test_header_unbuffered_when_continues	IJ"#'1$'')N62C8'--g6$<=C($67rcP|j}t|_|jd}|j|dd|j	|dd|j|jj|jtd|ddDd||_y)Nrzrs!HTTP/1.1 417 Expectation Failed
rr_c3&K|]	}|dk(yw)sConnection: close
Nr)rCrs  rrFzMBaseHTTPRequestHandlerTestCase.test_with_continue_rejected.<locals>.<genexpr>sQqQ"::Qs)r5r$r>rrHrcrrG)r
usual_handlerrgs   rtest_with_continue_rejectedz:BaseHTTPRequestHandlerTestCase.test_with_continue_rejecteds
8:**+\]$JK$$VAb\2	
001QF1RLQQSTU$rc|jdddzz}|j|dd|j|jj|j|jjty)NsGET xrs#HTTP/1.1 414 Request-URI Too Long
)r>rrcr5rassertIsInstancerbr{rfs  rtest_request_lengthz2BaseHTTPRequestHandlerTestCase.test_request_lengthsd**7TE\+AB$LM001dll66<rc|jdddzzdz}|j|dd|j|jj|j|jj
dy)NsGET / HTTP/1.1
X-Foo: barrrs

rsHTTP/1.1 431 Line too long
r`r>rrcr5rrbrfs  rtest_header_lengthz1BaseHTTPRequestHandlerTestCase.test_header_lengthsl**+dUl:[HJ$EF001113CDrc|jd}|j|dd|j|jj|j|jj
dy)NsGET / HTTP/1.1
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar
X-Foo: bar

rsHTTP/1.1 431 Too many headers
r`rrfs  rtest_too_many_headersz4BaseHTTPRequestHandlerTestCase.test_too_many_headerss^**EG$HI001113CDrc|jd}dj|}d}|jtj|djd|y)Ns*<script>alert("hello")</script> / HTTP/1.1rz<script>alert("hello")</script>FrDr)r>r9rrOrPr|)rrgtexts   rtest_html_escape_on_errorz8BaseHTTPRequestHandlerTestCase.test_html_escape_on_errorsL**9;&!0

dkk$e4;;GDfMrc6fd}|j_tdjjj	t
ttdjjj	t
ty)Nc:tj_yr)nextr5close_connection)close_valuesrsrr9zPBaseHTTPRequestHandlerTestCase.test_close_connection.<locals>.handle_one_requests,0,>DLL)r)T)FFT)r5r9iterhandler
StopIterationr)rr9rs` @rtest_close_connectionz4BaseHTTPRequestHandlerTestCase.test_close_connectionsl	?*<'G}-|<01-|<rc	6tj}tj|\	}}}}}}}}	}
d|jj|||jj|||||fz}|j|jj
||y)Nz#%s, %02d %3s %4d %02d:%02d:%02d GMT)r")timegmtimer5weekdayname	monthnamerdate_time_string)rnowyearmonthdayhhmmsswdyzrs            rtest_date_time_stringz4BaseHTTPRequestHandlerTestCase.test_date_time_stringsiik15S1A.eS"b"b!Q8LL$$R(LL""5)"b"	<

	
666ExPrN)r r!r"__doc__recompilerJrGr>r@rHrMr\rhrmrorsrxr{rrrrrrrrrrrrrrr3r3s
#

#:;2"1O$B*
C
C!2H
H... 8,
%=EEN
=
Qrr3c(eZdZdZdZdZdZdZy) SimpleHTTPRequestHandlerTestCasez Test url parsing ctjjtjd|_tjjdd|_tjjdd|_t|_td|_	ttjd|_y)NrRrrr)
rArr9rtranslated_1translated_2translated_3r	handler_1	handler_2pathlibPurePath	handler_3r5s rrGz&SimpleHTTPRequestHandlerTestCase.setUpszGGLLjAGGLL
;GGLL
;131EB1G<L<LU<STrc|jjd}|j||j|jjd}|j||j
|jjd}|j||j|jjd}|j||j|jjd}|j||j
|jjd}|j||j|jjd}|j||j|jjd}|j||j
|jjd}|j||jy)Nz	/filenamez/filename?foo=barz/filename?a=b&spam=eggs#zotrtranslate_pathrrrrrrrrs  rtest_query_argumentsz5SimpleHTTPRequestHandlerTestCase.test_query_argumentss~~,,[9t001~~,,[9t001~~,,[9t001~~,,-@At001~~,,-@At001~~,,-@At001~~,,-JKt001~~,,-JKt001~~,,-JKt001rc|jjd}|j||j|jjd}|j||j
|jjd}|j||j|jjd}|j||j|jjd}|j||j
|jjd}|j||jy)Nz
//filenamez//filename?foo=barrrs  rtest_start_with_double_slashz=SimpleHTTPRequestHandlerTestCase.test_start_with_double_slashs~~,,\:t001~~,,\:t001~~,,\:t001~~,,-ABt001~~,,-ABt001~~,,-ABt001rc	tjtjdt5|j
j
d}|jtjtj}|j||j|jj
d}|jtjtj}|j||j|jj
d}|jtjtj}|j||j|j
j
d}|jtjtj}|j||j|jj
d}|jtjtj}|j||j|jj
d}|jtjtj}|j||j|j
j
d}|jtjtj}|j||j|jj
d}|jtjtj}|j||j|jj
d}|jtjtj}|j||j|j
j
d}|jtjtj}|j||j|jj
d}|jtjtj}|j||j|jj
d}|jtjtj}|j||jdddy#1swYyxYw)Nrzc:c:c:foo/filenamez\c:../filenamezc:\c:..\foo/filenamezc:c:foo\c:c:bar/filename)r
	swap_attrrrAntpathrrrseprrrrrrrs  rtest_windows_colonz3SimpleHTTPRequestHandlerTestCase.test_windows_colonsR


vyy&&
9'	6>>001EFD<<

BFF3DT4#4#45>>001EFD<<

BFF3DT4#4#45>>001EFD<<

BFF3DT4#4#45>>001BCD<<

BFF3DT4#4#45>>001BCD<<

BFF3DT4#4#45>>001BCD<<

BFF3DT4#4#45>>001IJD<<

BFF3DT4#4#45>>001IJD<<

BFF3DT4#4#45>>001IJD<<

BFF3DT4#4#45>>001LMD<<

BFF3DT4#4#45>>001LMD<<

BFF3DT4#4#45>>001LMD<<

BFF3DT4#4#45O'	6'	6'	6sR=S00S9N)r r!r"rrGrrrrrrrrsU2,
2(6rrceZdZdZy)MiscTestCasecg}hd}ttD]J}|jds||vrtt|}t|dddk(s:|j	|L|jtj|y)N>rr
nobody_uid_r!zhttp.server)rrrdgetattrrassertCountEqual__all__)rrdenylistrT
module_objects     rtest_allzMiscTestCase.test_allBst7K	&Ds#tx'7#FD1M}lD9]J%	&	
fnnh7rN)r r!r"rrrrrrAs	8rrceZdZdZej
ddZej
ddZdZdZ	ej
ddZ
ej
ddZy	)
ScriptTestCasectjtjtjtjtjdS)Ncy)N)rrrrrr<lambda>z2ScriptTestCase.mock_server_class.<locals>.<lambda>Vsr)r.)r-)r)r)r
	MagicMockr5s rmock_server_classz ScriptTestCase.mock_server_classPsF~~..!%#~~(7 "


	
rzbuiltins.printc|j}tj|d|j|jt
jt
jfyNServerClassbindrrrraddress_familyr-AF_INET6AF_INETrrmock_servers   rtest_server_test_unspecz&ScriptTestCase.test_server_test_unspec]sC,,.$7

&&
__fnn-	
rc|j}tj|d|j|jt
jt
jfy)Nr,rrrs   rtest_server_test_localhostz)ScriptTestCase.test_server_test_localhostfsC,,.+>

&&
__fnn-	
r)z::z'2001:0db8:85a3:0000:0000:8a2e:0370:7334z::1)z0.0.0.0z8.8.8.8rOc|jD]S}|j}tj|||j	|j
tjUyr)
ipv6_addrsrrrrrr-rrrrrs    rtest_server_test_ipv6z$ScriptTestCase.test_server_test_ipv6{sMOO	JD002KKKKd;[77I	Jrc|jD]S}|j}tj|||j	|j
tjUyr)
ipv4_addrsrrrrrr-rrs    rtest_server_test_ipv4z$ScriptTestCase.test_server_test_ipv4sMOO	ID002KKKKd;[77H	IrN)r r!r"rr
rWrrrrrrrrrrrNs
TZZ !
"
TZZ !
"
JJTZZ !J"JTZZ !I"Irrcptjtjtjyr)raddModuleCleanuprArrrrrsetUpModulersbhh		4r__main__)Drcollectionsrhttp.serverrrrrrNrr	rAr-rGrrrrr+
email.messageremail.utilsrOhttp.clienturllib.parserMr
rrr&rr
riorrrr
test.supportrrrequires_working_socketrr'r$TestCaser<rYrrrrrrrhasattrrwrrr$r)r3rrrrr mainrrr<module>r
s
$55#	

	


 ")t,y''*-8$$-*a(\a(H!GL!GH`3|`3F	
	
	"
	
	&Y'=JBJJLA,=AC~4L~4C~4B
7
&(@

 }QX%6%6}Q@W6x'8'8W6t
88$$
89IX&&9Ix5zHMMOr