Critics have remarked that those four worthies were truly peerless throughout the ages; yet the present falls short of the pastβ€”the ancients favored unadorned simplicity, whereas the moderns prefer refined elegance. Styles of substance and ornament rise and fall in succession, shifting with the changing mores of the times; such evolution is simply the natural order of things. The ideal lies in honoring antiquity without clashing with the present, and embracing modernity without succumbing to its flawsβ€”embodying that perfect balance of substance and refinement that defines the true gentleman. There is surely no need to abandon a carved palace in favor of a cave dwelling, or to trade a jade carriage for a primitive cart with solid wooden wheels.🌌 SpectraShell

🌌 SpectraShell

Current path: lib64/python2.7/



⬆️ Go up: /lib64

πŸ“„ Viewing: CGIHTTPServer.pyo

οΏ½
zfc@sοΏ½dZdZdgZddlZddlZddlZddlZddlZddlZddl	Z	dej
fdοΏ½οΏ½YZdοΏ½Ze
adοΏ½ZdοΏ½Zeejd	οΏ½Zed
krοΏ½eοΏ½ndS(sοΏ½CGI-savvy HTTP Server.

This module builds on SimpleHTTPServer by implementing GET and POST
requests to cgi-bin scripts.

If the os.fork() function is not present (e.g. on Windows),
os.popen2() is used as a fallback, with slightly altered semantics; if
that function is not present either (e.g. on Macintosh), only Python
scripts are supported, and they are executed by the current process.

In all cases, the implementation is intentionally naive -- all
requests are executed sychronously.

SECURITY WARNING: DON'T USE THIS CODE UNLESS YOU ARE INSIDE A FIREWALL
-- it may execute arbitrary Python code or external programs.

Note that status code 200 is sent prior to execution of a CGI script, so
scripts cannot send other status codes such as 302 (redirect).
s0.4tCGIHTTPRequestHandleriοΏ½οΏ½οΏ½οΏ½NcBsοΏ½eZdZeedοΏ½ZeedοΏ½ZeedοΏ½ZdZdοΏ½Z	dοΏ½Z
dοΏ½Zdd	gZd
οΏ½Z
dοΏ½ZdοΏ½ZRS(
sοΏ½Complete HTTP server with GET, HEAD and POST commands.

    GET and HEAD also support running CGI scripts.

    The POST command is *only* implemented for CGI scripts.

    tforktpopen2tpopen3icCs-|jοΏ½r|jοΏ½n|jddοΏ½dS(sRServe a POST request.

        This is only implemented for CGI scripts.

        iοΏ½sCan only POST to CGI scriptsN(tis_cgitrun_cgit
send_error(tself((s%/usr/lib64/python2.7/CGIHTTPServer.pytdo_POST6s
cCs*|jοΏ½r|jοΏ½Stjj|οΏ½SdS(s-Version of send_head that support CGI scriptsN(RRtSimpleHTTPServertSimpleHTTPRequestHandlert	send_head(R((s%/usr/lib64/python2.7/CGIHTTPServer.pyRBs
cCs`t|jοΏ½}|jddοΏ½}|| ||d}}||jkr\||f|_tStS(s2Test whether self.path corresponds to a CGI script.

        Returns True and updates the cgi_info attribute to the tuple
        (dir, rest) if self.path requires running a CGI script.
        Returns False otherwise.

        If any exception is raised, the caller should assume that
        self.path was rejected as invalid and act accordingly.

        The default implementation tests whether the normalized url
        path begins with one of the strings in self.cgi_directories
        (and the next character is a '/' or the end of the string).
        t/i(t_url_collapse_pathtpathtfindtcgi_directoriestcgi_infotTruetFalse(Rtcollapsed_pathtdir_septheadttail((s%/usr/lib64/python2.7/CGIHTTPServer.pyRIss/cgi-bins/htbincCs
t|οΏ½S(s1Test whether argument path is an executable file.(t
executable(RR((s%/usr/lib64/python2.7/CGIHTTPServer.pyt
is_executableascCs(tjj|οΏ½\}}|jοΏ½dkS(s.Test whether argument path is a Python script.s.pys.pyw(s.pys.pyw(tosRtsplitexttlower(RRRR((s%/usr/lib64/python2.7/CGIHTTPServer.pyt	is_pythonesc)
CsοΏ½|j\}}|d|}|jdt|οΏ½dοΏ½}xv|dkrοΏ½|| }||d}|j|οΏ½}tjj|οΏ½rοΏ½||}}|jdt|οΏ½dοΏ½}q<Pq<W|jdοΏ½\}}}	|jdοΏ½}|dkrοΏ½|| ||}
}n
|d}
}|d|
}|j|οΏ½}tjj|οΏ½sQ|j	dd|οΏ½dStjj
|οΏ½s{|j	d	d
|οΏ½dS|j|οΏ½}
|
sοΏ½|jpοΏ½|j
pοΏ½|jsοΏ½|j	d	d|οΏ½dS|j|οΏ½sοΏ½|j	d	d|οΏ½dSntjtjοΏ½}|jοΏ½|d
<|jj|d<d|d<|j|d<t|jjοΏ½|d<|j|d<tj|οΏ½}||d<|j|οΏ½|d<||d<|	rοΏ½|	|d<n|jοΏ½}||jdkrοΏ½||d<n|jd|d<|jjdοΏ½}|rοΏ½|j οΏ½}t|οΏ½dkrοΏ½ddl!}ddl"}|d|d<|dj#οΏ½dkrοΏ½y|j$|dοΏ½}Wn|j%k
r~qοΏ½X|j dοΏ½}t|οΏ½dkrοΏ½|d|d <qοΏ½qοΏ½qοΏ½n|jj&dkrοΏ½|jj(|d!<n|jj&|d!<|jjd"οΏ½}|r||d#<n|jjd$οΏ½}|r9||d%<ng}xW|jj)d&οΏ½D]C}|d d'kr~|j*|j+οΏ½οΏ½qR||d(j d)οΏ½}qRWd)j,|οΏ½|d*<|jjd+οΏ½}|rοΏ½||d,<nt-d|jj.d-οΏ½οΏ½}|rd.j,|οΏ½|d/<nxdCD]}|j/|dοΏ½qW|j0d0d1οΏ½|	j1d2d3οΏ½}|jrοΏ½|
g}d4|kry|j*|οΏ½nt2οΏ½}|j3j4οΏ½tj5οΏ½}|dkrtj6|dοΏ½\}}x<t7j7|j8gggdοΏ½drοΏ½|j8j9dοΏ½sοΏ½PqοΏ½qοΏ½W|r|j:d5|οΏ½ndSyqytj;|οΏ½Wntj<k
rEnXtj=|j8j>οΏ½dοΏ½tj=|j3j>οΏ½dοΏ½tj?|||οΏ½WqοΏ½|jj@|jA|jοΏ½tjBd6οΏ½qοΏ½XnddlC} |g}!|j|οΏ½r)tDjE}"|"j#οΏ½jFd7οΏ½r|"d8 |"d9}"n|"d:g|!}!nd4|	krE|!j*|	οΏ½n|jGd;| jH|!οΏ½οΏ½ytI|οΏ½}#WntJtKfk
rοΏ½d}#nX| jL|!d<| jMd=| jMd>| jMd?|οΏ½}$|jj#οΏ½d@krοΏ½|#dkrοΏ½|j8j9|#οΏ½}%nd}%xBt7j7|j8jNgggdοΏ½dr>|j8jNjOdοΏ½sοΏ½PqοΏ½qοΏ½W|$jP|%οΏ½\}&}'|j3jQ|&οΏ½|'r}|j:dA|'οΏ½n|$jRjSοΏ½|$jTjSοΏ½|$jU}(|(rοΏ½|j:d5|(οΏ½n
|jGdBοΏ½dS(DsExecute a CGI script.Riit?tiοΏ½sNo such CGI script (%r)NiοΏ½s#CGI script is not a plain file (%r)s&CGI script is not a Python script (%r)s!CGI script is not executable (%r)tSERVER_SOFTWAREtSERVER_NAMEsCGI/1.1tGATEWAY_INTERFACEtSERVER_PROTOCOLtSERVER_PORTtREQUEST_METHODt	PATH_INFOtPATH_TRANSLATEDtSCRIPT_NAMEtQUERY_STRINGtREMOTE_HOSTtREMOTE_ADDRt
authorizationiiοΏ½οΏ½οΏ½οΏ½t	AUTH_TYPEtbasict:tREMOTE_USERtCONTENT_TYPEscontent-lengthtCONTENT_LENGTHtreferertHTTP_REFERERtaccepts	

 it,tHTTP_ACCEPTs
user-agenttHTTP_USER_AGENTtcookies, tHTTP_COOKIEiοΏ½sScript output followst+t t=sCGI script exit status %#xisw.exeiοΏ½οΏ½οΏ½οΏ½iοΏ½οΏ½οΏ½οΏ½s-uscommand: %ststdintstdouttstderrtenvtposts%ssCGI script exited OK(R)R*R2R8R:R4(VRRtlenttranslate_pathRRtisdirt	partitiontexistsRtisfileRt	have_forkthave_popen2thave_popen3Rtcopytdeepcopytenvirontversion_stringtservertserver_nametprotocol_versiontstrtserver_porttcommandturllibtunquotetaddress_stringtclient_addresstheaderst	getheadertsplittbase64tbinasciiRtdecodestringtErrort
typeheadertNonettypetgetallmatchingheaderstappendtstriptjointfiltert
getheaderst
setdefaultt
send_responsetreplacet
nobody_uidtwfiletflushRtwaitpidtselecttrfiletreadt	log_errortsetuidterrortdup2tfilenotexecvethandle_errortrequestt_exitt
subprocesstsysRtendswithtlog_messagetlist2cmdlinetintt	TypeErrort
ValueErrortPopentPIPEt_socktrecvtcommunicatetwriteR@tcloseR?t
returncode()RtdirtrestRtitnextdirtnextrestt	scriptdirt_tquerytscriptt
scriptnamet
scriptfiletispyRAtuqrestthostR,R]R^tlengthR3R5tlinetuatcotkt
decoded_querytargstnobodytpidtstsR}tcmdlinetinterptnbytestptdataR?R@tstatus((s%/usr/lib64/python2.7/CGIHTTPServer.pyRjs2













			
%		
				!(

	(t__name__t
__module__t__doc__thasattrRRIRJRKtrbufsizeRRRRRRR(((s%/usr/lib64/python2.7/CGIHTTPServer.pyR#s					c	Cs.|jdοΏ½\}}}tj|οΏ½}|jdοΏ½}g}xM|d D]A}|dkrf|jοΏ½qG|rG|dkrG|j|οΏ½qGqGW|rοΏ½|jοΏ½}|rοΏ½|dkrοΏ½|jοΏ½d}qοΏ½|dkrοΏ½d}qοΏ½qοΏ½nd}|rdj||fοΏ½}nddj|οΏ½|f}dj|οΏ½}|S(sοΏ½
    Given a URL path, remove extra '/'s and '.' path elements and collapse
    any '..' references and returns a colllapsed path.

    Implements something akin to RFC-2396 5.2 step 6 to parse relative paths.
    The utility of this function is limited to is_cgi method and helps
    preventing some security attacks.

    Returns: The reconstituted URL, which will always start with a '/'.

    Raises: IndexError if too many '..' occur within the path.

    RRiοΏ½οΏ½οΏ½οΏ½s..t.R(RFRVRWR\tpopReRg(	RRοΏ½RοΏ½t
path_partst
head_partstpartt	tail_partt	splitpathR((s%/usr/lib64/python2.7/CGIHTTPServer.pyR
*s.

	cCsοΏ½tr
tSyddl}Wntk
r.dSXy|jdοΏ½daWn3tk
r{dttdοΏ½|jοΏ½οΏ½οΏ½anXtS(s$Internal routine to get nobody's uidiοΏ½οΏ½οΏ½οΏ½NRοΏ½iicSs|dS(Ni((tx((s%/usr/lib64/python2.7/CGIHTTPServer.pyt<lambda>gR(RοΏ½tpwdtImportErrortgetpwnamtKeyErrortmaxtmaptgetpwall(RοΏ½((s%/usr/lib64/python2.7/CGIHTTPServer.pyRm[s

&cCs<ytj|οΏ½}Wntjk
r*tSX|jd@dkS(sTest for executable file.iIi(RtstatRvRtst_mode(Rtst((s%/usr/lib64/python2.7/CGIHTTPServer.pyRks
cCstj||οΏ½dS(N(R	ttest(tHandlerClasstServerClass((s%/usr/lib64/python2.7/CGIHTTPServer.pyRοΏ½tst__main__(RοΏ½t__version__t__all__RR~RVtBaseHTTPServerR	RqRLR
RR
RbRοΏ½RmRt
HTTPServerRοΏ½RοΏ½(((s%/usr/lib64/python2.7/CGIHTTPServer.pyt<module>s&	οΏ½	/			


πŸ“