python (3.11.7)

(root)/
lib/
python3.11/
http/
__pycache__/
server.cpython-311.opt-1.pyc

e_zdZdZgdZddlZddlZddlZddlZddlZ	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZddl	mZdZdZGdd	ejZGd
dejeZGdd
ejZGddeZ dZ!da"dZ#dZ$Gdde Z%dZ&eedddfdZ'e(dkrddl)Z)ddl*Z*e)j+Z,e,-ddde,-ddd d!"e,-d#d$e
j.d%&e,-d'd(d)dd*+e,-d,de/d-d./e,0Z1e1j2re%Z3ne Z3Gd0d1eZ4e'e3e4e1j5e1j6e1j72dSdS)3a@HTTP server classes.

Note: BaseHTTPRequestHandler doesn't implement any HTTP request; see
SimpleHTTPRequestHandler for simple implementations of GET, HEAD and POST,
and CGIHTTPRequestHandler for CGI scripts.

It does, however, optionally implement HTTP/1.1 persistent connections,
as of version 0.3.

Notes on CGIHTTPRequestHandler
------------------------------

This class implements GET and POST requests to cgi-bin scripts.

If the os.fork() function is not present (e.g. on Windows),
subprocess.Popen() is used as a fallback, with slightly altered semantics.

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

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).

XXX To do:

- log requests even later (to capture byte count)
- log user-agent header and other interesting goodies
- send error log to separate file
z0.6)
HTTPServerThreadingHTTPServerBaseHTTPRequestHandlerSimpleHTTPRequestHandlerCGIHTTPRequestHandlerN)
HTTPStatusaD<!DOCTYPE HTML>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Error response</title>
    </head>
    <body>
        <h1>Error response</h1>
        <p>Error code: %(code)d</p>
        <p>Message: %(message)s.</p>
        <p>Error code explanation: %(code)s - %(explain)s.</p>
    </body>
</html>
ztext/html;charset=utf-8ceZdZdZdZdS)rctj||jdd\}}t	j||_||_dS)z.Override server_bind to store the server name.N)socketserver	TCPServerserver_bindserver_addresssocketgetfqdnserver_nameserver_port)selfhostports   ?/BuggyBox/python/3.11.7/bootstrap/lib/python3.11/http/server.pyrzHTTPServer.server_bindsN**4000(!,
d!>$//N)__name__
__module____qualname__allow_reuse_addressrrrrrs)     rrceZdZdZdS)rTN)rrrdaemon_threadsrrrrrsNNNrrc
eZdZdZdejdzZdezZ	e
ZeZ
dZdZdZdZd	Zd#dZd$dZd$d
ZdZdZdZd%dZdZedejededdDZ de e!d<dZ"dZ#d$dZ$dZ%gdZ&gdZ'd Z(d!Z)e*j+j,Z-d"e.j/0DZ1d
S)&raHTTP request handler base class.

    The following explanation of HTTP serves to guide you through the
    code as well as to expose any misunderstandings I may have about
    HTTP (so you don't need to read the code to figure out I'm wrong
    :-).

    HTTP (HyperText Transfer Protocol) is an extensible protocol on
    top of a reliable stream transport (e.g. TCP/IP).  The protocol
    recognizes three parts to a request:

    1. One line identifying the request type and path
    2. An optional set of RFC-822-style headers
    3. An optional data part

    The headers and data are separated by a blank line.

    The first line of the request has the form

    <command> <path> <version>

    where <command> is a (case-sensitive) keyword such as GET or POST,
    <path> is a string containing path information for the request,
    and <version> should be the string "HTTP/1.0" or "HTTP/1.1".
    <path> is encoded using the URL encoding scheme (using %xx to signify
    the ASCII character with hex code xx).

    The specification specifies that lines are separated by CRLF but
    for compatibility with the widest range of clients recommends
    servers also handle LF.  Similarly, whitespace in the request line
    is treated sensibly (allowing multiple spaces between components
    and allowing trailing whitespace).

    Similarly, for output, lines ought to be separated by CRLF pairs
    but most clients grok LF characters just fine.

    If the first line of the request has the form

    <command> <path>

    (i.e. <version> is left out) then this is assumed to be an HTTP
    0.9 request; this form has no optional headers and data part and
    the reply consists of just the data.

    The reply form of the HTTP 1.x protocol again has three parts:

    1. One line giving the response code
    2. An optional set of RFC-822-style headers
    3. The data

    Again, the headers and data are separated by a blank line.

    The response code line has the form

    <version> <responsecode> <responsestring>

    where <version> is the protocol version ("HTTP/1.0" or "HTTP/1.1"),
    <responsecode> is a 3-digit response code indicating success or
    failure of the request, and <responsestring> is an optional
    human-readable string explaining what the response code means.

    This server parses the request and the headers, and then calls a
    function specific to the request type (<command>).  Specifically,
    a request SPAM will be handled by a method do_SPAM().  If no
    such method exists the server sends an error response to the
    client.  If it exists, it is called with no arguments:

    do_SPAM()

    Note that the request name is case sensitive (i.e. SPAM and spam
    are different requests).

    The various request details are stored in instance variables:

    - client_address is the client IP address in the form (host,
    port);

    - command, path and version are the broken-down request line;

    - headers is an instance of email.message.Message (or a derived
    class) containing the header information;

    - rfile is a file object open for reading positioned at the
    start of the optional input data part;

    - wfile is a file object open for writing.

    IT IS IMPORTANT TO ADHERE TO THE PROTOCOL FOR WRITING!

    The first thing to be written must be the response line.  Then
    follow 0 or more header lines, then a blank line, and then the
    actual data (if any).  The meaning of the header lines depends on
    the command executed by the server; in most cases, when data is
    returned, there should be at least one header line of the form

    Content-type: <type>/<subtype>

    where <type> and <subtype> should be registered MIME types,
    e.g. "text/html" or "text/plain".

    zPython/rz	BaseHTTP/HTTP/0.9cd|_|jx|_}d|_t	|jd}|d}||_|}t|dkrdSt|dkrp|d}	|
d	st|d
dd}|d}t|d
krttd|Drtdtd|Drtdt|dt|df}n;#ttf$r'|t jd|zYdSwxYw|dkr|jdkrd|_|dkr%|t jd|zdS||_d
t|cxkrdks'n|t jd|zdS|dd
\}}t|d
kr2d|_|dkr%|t jd|zdS||c|_|_|j
dr"d
|jd
z|_	t,j|j|j|_n#t,jj$r9}|t jdt	|Yd}~dSd}~wt,jj$r9}|t jdt	|Yd}~dSd}~wwxYw|jdd}	|	 d krd|_n*|	 d!kr|jdkrd|_|jd"d}
|
 d#kr,|jdkr!|jdkr|!sdSdS)$aHParse a request (internal).

        The request should be stored in self.raw_requestline; the results
        are in self.command, self.path, self.request_version and
        self.headers.

        Return True for success, False for failure; on failure, any relevant
        error response has already been sent back.

        NTz
iso-8859-1
rFzHTTP//r
.rc3@K|]}|VdSN)isdigit.0	components  r	<genexpr>z7BaseHTTPRequestHandler.parse_request.<locals>.<genexpr>/s1OO99,,...OOOOOOrznon digit in http versionc3<K|]}t|dkVdS)
N)lenr,s  rr/z7BaseHTTPRequestHandler.parse_request.<locals>.<genexpr>1s-KKys9~~*KKKKKKrz unreasonable length http versionzBad request version (%r))r
r
zHTTP/1.1)rrzInvalid HTTP version (%s)zBad request syntax (%r)GETzBad HTTP/0.9 request type (%r)z//)_classz
Line too longzToo many headers
Connectionclose
keep-aliveExpectz100-continue)"commanddefault_request_versionrequest_versionclose_connectionstrraw_requestlinerstriprequestlinesplitr2
startswith
ValueErroranyint
IndexError
send_errorrBAD_REQUESTprotocol_versionHTTP_VERSION_NOT_SUPPORTEDpathlstriphttpclient
parse_headersrfileMessageClassheadersLineTooLongREQUEST_HEADER_FIELDS_TOO_LARGE
HTTPExceptiongetlowerhandle_expect_100)rversionrAwordsbase_version_numberversion_numberr:rLerrconntypeexpects           r
parse_requestz$BaseHTTPRequestHandler.parse_requests)-)EEw $$.==!((00&!!##u::??5u::??BiG
))'22%$$&-mmC&;&;A&>#!4!:!:3!?!?~&&!++$$OOOOOOOB$%@AAAKKNKKKKKI$%GHHH!$^A%6!7!7^A=N9O9O!O
+


*.8:::uu	

''D,AZ,O,O(-%''9/2EEGGGu#*D CJJ####!####OO&)K7
9
9
95bqb	
u::??$(D!%*4w>@@@u")4di9%%	4di..s333DI	;44TZ<@<M5OODLL{&			OO:C


55555{(			OO:"C



55555
	<##L"55>>w&&$(D!!nn,..#z11$)D!!!(B//LLNNn,,%33$
22))++
uts7C!E664F.-F.0LN#.MN#*.NN#cl|tj|dS)a7Decide what to do with an "Expect: 100-continue" header.

        If the client is expecting a 100 Continue response, we must
        respond with either a 100 Continue or a final response before
        waiting for the request body. The default is to always respond
        with a 100 Continue. You can behave differently (for example,
        reject unauthorized requests) by overriding this method.

        This method should either return True (possibly after sending
        a 100 Continue response) or send an error response and return
        False.

        T)send_response_onlyrCONTINUEend_headersrs rrYz(BaseHTTPRequestHandler.handle_expect_100ys2	

 3444trc	|jd|_t|jdkr6d|_d|_d|_|tj	dS|js	d|_
dS|sdSd|jz}t||s*|tj
d|jzdSt||}||jdS#t"$r(}|d|d|_
Yd}~dSd}~wwxYw)	zHandle a single HTTP request.

        You normally don't need to override this method; see the class
        __doc__ string for information on how to handle specific HTTP
        commands such as GET and POST.

        iir6NTdo_zUnsupported method (%r)zRequest timed out: %r)rQreadliner?r2rAr<r:rHrREQUEST_URI_TOO_LONGr=rahasattrNOT_IMPLEMENTEDgetattrwfileflushTimeoutError	log_error)rmnamemethodes    rhandle_one_requestz)BaseHTTPRequestHandler.handle_one_requests_	#':#6#6u#=#=D 4'((500#% ')$!
 ?@@@'
(,%%%''
DL(E4''
.-<>>>T5))FFHHHJ			NN2A666$(D!FFFFF		s1A+D/D?DAD3D
ED;;Ecd|_||js||jdSdS)z&Handle multiple requests if necessary.TN)r=rurfs rhandlezBaseHTTPRequestHandler.handlesZ $!!!'	&##%%%'	&	&	&	&	&rNc	|j|\}}n#t$rd\}}YnwxYw||}||}|d||||||ddd}|dkr|t
jt
jt
jfvr|j	|tj|dtj|dd	z}|d
d}|d|j
|d
tt|||jdkr|r|j|dSdSdS)akSend and log an error reply.

        Arguments are
        * code:    an HTTP error code
                   3 digits
        * message: a simple optional 1 line reason phrase.
                   *( HTAB / SP / VCHAR / %x80-FF )
                   defaults to short entry matching the response code
        * explain: a detailed message defaults to the long entry
                   matching the response code.

        This sends an error response (so it must be called before any
        output has been generated), logs the error, and finally sends
        a piece of HTML explaining the error to the user.

        )???ryNzcode %d, message %sr5r7Fquote)codemessageexplainzUTF-8replacezContent-TypeContent-LengthHEAD)	responsesKeyErrorrq
send_responsesend_headerr
NO_CONTENT
RESET_CONTENTNOT_MODIFIEDerror_message_formathtmlescapeencodeerror_content_typer>r2rer:rnwrite)rr}r~rshortmsglongmsgbodycontents        rrHz!BaseHTTPRequestHandler.send_errors$	- $t 4Hgg	-	-	- ,Hggg	-?G?G,dG<<<4)))w///
CKK.#1#02
2
2
0;we<<<;we<<<44G
>>'955D^T-DEEE-s3t99~~>>><6!!d!JT""""""!!!s%%c||||||d||d|dS)zAdd the response header to the headers buffer and log the
        response code.

        Also send two standard headers with the server software
        version and the current date.

        ServerDateN)log_requestrcrversion_stringdate_time_stringrr}r~s   rrz$BaseHTTPRequestHandler.send_responsesx	
g...4#6#6#8#8999!6!6!8!899999rc|jdkrs|||jvr|j|d}nd}t|dsg|_|jd|j||fzdddSdS)	zSend the response header only.r"Nrr6_headers_bufferz
%s %d %s
latin-1strict)r<rrkrappendrJrrs   rrcz)BaseHTTPRequestHandler.send_response_onlys:--4>))"nT215GG G4!233
*')$ ''*D':*;<BF!8=-=-
.
.
.
.
..-rcj|jdkrKt|dsg|_|j|d|ddd|dkrB|dkr	d	|_dS|d
krd|_dSdSdS)
z)Send a MIME header to the headers buffer.r"rz: r$rr
connectionr7Tr8FN)r<rkrrrrXr=)rkeywordvalues   rrz"BaseHTTPRequestHandler.send_headers:--4!233
*')$ ''!(%%%088HMM
O
O
O==??l**{{}}''(,%%%,..(-%%%	+*/.rc||jdkr0|jd|dSdS)z,Send the blank line ending the MIME headers.r"s
N)r<rr
flush_headersrfs rrez"BaseHTTPRequestHandler.end_headerssG:-- ''000     .-rct|dr;|jd|jg|_dSdS)Nrr)rkrnrjoinrrfs rrz$BaseHTTPRequestHandler.flush_headerssR4*++	&JSXXd&:;;<<<#%D   	&	&r-ct|tr|j}|d|jt|t|dS)zNLog an accepted request.

        This is called by send_response().

        z
"%s" %s %sN)
isinstancerrlog_messagerAr>)rr}sizes   rrz"BaseHTTPRequestHandler.log_request!s\dJ''	:D)3t99c$ii	A	A	A	A	Arc"|j|g|RdS)zLog an error.

        This is called when a request cannot be fulfilled.  By
        default it passes the message on to log_message().

        Arguments are the same as for log_message().

        XXX This should go to the separate error log.

        N)r)rformatargss   rrqz BaseHTTPRequestHandler.log_error,s%	'$''''''rci|]	}|d|d
S)z\x02xr)r-cs  r
<dictcomp>z!BaseHTTPRequestHandler.<dictcomp><s"VVV!Q
a


VVVr z\\\c	||z}tj|d|d||jddS)aZLog an arbitrary message.

        This is used by all other logging functions.  Override
        it if you have specific logging wishes.

        The first argument, FORMAT, is a format string for the
        message to be logged.  If the format string contains
        any % escapes requiring parameters, they should be
        specified as subsequent arguments (it's just like
        printf!).

        The client ip and current date/time are prefixed to
        every message.

        Unicode control characters are replaced with escaped hex
        before writing the output to stderr.

        z - - [z] 
N)sysstderrraddress_stringlog_date_time_string	translate_control_char_table)rrrr~s    rrz"BaseHTTPRequestHandler.log_message?s(4-
--////335555!++D,DEEEEG	H	H	H	H	Hrc&|jdz|jzS)z*Return the server software version string. )server_versionsys_versionrfs rrz%BaseHTTPRequestHandler.version_stringYs"S(4+;;;rcn|tj}tj|dS)z@Return the current date and time formatted for a message header.NT)usegmt)timeemailutils
formatdate)r	timestamps  rrz'BaseHTTPRequestHandler.date_time_string]s.	I{%%i%===rc	tj}tj|\	}}}}}}}}	}
d||j|||||fz}|S)z.Return the current time formatted for logging.z%02d/%3s/%04d %02d:%02d:%02d)r	localtime	monthname)rnowyearmonthdayhhmmssxyzss            rrz+BaseHTTPRequestHandler.log_date_time_stringcsWikk04s0C0C-eS"b"aA*T^E*D"b".>
>r)MonTueWedThuFriSatSun)
NJanFebMarAprMayJunJulAugSepOctNovDecc|jdS)zReturn the client address.r)client_addressrfs rrz%BaseHTTPRequestHandler.address_stringqs"1%%rHTTP/1.0c,i|]}||j|jfSr)phrasedescription)r-vs  rrz!BaseHTTPRequestHandler.<dictcomp>s3
	
AHam$r)NNr*)rr)2rrr__doc__rrZrBr__version__rDEFAULT_ERROR_MESSAGErDEFAULT_ERROR_CONTENT_TYPErr;rarYrurwrHrrcrrerrrqr>	maketrans	itertoolschainrangerordrrrrweekdaynamerrrJrNrOHTTPMessagerRr__members__valuesrrrrrrs=ddNck//11!44K
!;.N03)lll\$###J&&&3#3#3#3#j::::.......!!!&&&
	A	A	A	A(((--VVyuuT{{EE$tDTDT'U'UVVVXX%*D		"HHH4<<<>>>>DCCK;;;I&&&";*L'..00IIIrrcneZdZdZdezZdddddxZZdd	fd

ZdZ	dZ
d
ZdZdZ
dZdZxZS)raWSimple HTTP request handler with GET and HEAD commands.

    This serves files from the current directory and any of its
    subdirectories.  The MIME type for files is determined by
    calling the .guess_type() method.

    The GET and HEAD requests are identical except that the HEAD
    request omits the actual contents of the file.

    zSimpleHTTP/zapplication/gzipapplication/octet-streamzapplication/x-bzip2zapplication/x-xz)z.gzz.Zz.bz2z.xzN	directoryc|tj}tj||_t	j|i|dSr*)osgetcwdfspathrsuper__init__)rrrkwargs	__class__s    rr	z!SimpleHTTPRequestHandler.__init__sG	I9--$)&)))))rc|}|rK	|||j|dS#|wxYwdS)zServe a GET request.N)	send_headcopyfilernr7rfs  rdo_GETzSimpleHTTPRequestHandler.do_GETsaNN	


a,,,												sA		Ac^|}|r|dSdS)zServe a HEAD request.N)r
r7rs  rdo_HEADz SimpleHTTPRequestHandler.do_HEADs4NN	
GGIIIII		rcd||j}d}tj|rCtj|j}|jds|tj
|d|d|ddz|d|df}tj|}|d||d	d
|
dSdD]E}tj||}tj|r|}nF||S||}|dr"|tjddS	t)|d
}n1#t*$r$|tjdYdSwxYw	tj|}d|jvr6d|jvr,	t2j|jd}	|	j%|	t<jj }	|	jt<jj urt<j!|j"t<jj }
|
d}
|
|	krI|tj#|
|$dSn##tJtLtNtPf$rYnwxYw|tj)|d||d	tU|d|d|+|j"|
|S#|$xYw)a{Common code for GET and HEAD commands.

        This sends the response code and MIME headers.

        Return value is either a file object (which has to be copied
        to the outputfile by the caller unless the command was HEAD,
        and must be closed by the caller under all circumstances), or
        None, in which case the caller has nothing further to do.

        Nr'rr
rr%Locationr0)z
index.htmlz	index.htmzFile not foundrbzIf-Modified-Sincez
If-None-Match)tzinfo)microsecondContent-typez
Last-Modified),translate_pathrLrisdirurllibparseurlsplitendswithrrMOVED_PERMANENTLY
urlunsplitrrerisfilelist_directory
guess_typerH	NOT_FOUNDopenOSErrorfstatfilenorSrrparsedate_to_datetimerrdatetimetimezoneutc
fromtimestampst_mtimerr7	TypeErrorrG
OverflowErrorrDOKr>r)rrLrparts	new_partsnew_urlindexctypefsims
last_modifs           rr
z"SimpleHTTPRequestHandler.send_heads""49--
7==	1L))$)44E:&&s++	
"":#?@@@"1XuQxqC"1XuQx1	 ,11)<<  W555  !13777  """t2
1
1T5117>>%(( DE**4000%%==	OOJ02BCCC4	T4  AA			OOJ02BCCC44	'	!((**%%B#t|33't|;;(+;;%89;;Cz)"kk1B1FkGGzX%6%:::%-%6%D%DK):)>&@&@
&0%7%7A%7%F%F
%,, ..z/FGGG ,,...GGIII#'4'":}jID*
z}---^U333-s2a5zz:::_%%bk22
4
4
4H	
GGIIIsJ
G*HH:P*M5CPPM30P2M33B$PP/c
	tj|}n1#t$r$|tjdYdSwxYw|dg}	tj	|j
d}n4#t$r'tj	|j
}YnwxYwtj
|d}tj}d	|}|d
|d|d|d
|d|d|d|d|d|d|D]}tj
||}|x}	}
tj
|r
|dz}	|dz}
tj
|r|dz}	|dtj|
ddtj
|	dd|dd||d}t-j}|||d|tj|dd|z|dt;t=|||S)zHelper to produce a directory listing (absent index.html).

        Return value is either a file object, or None (indicating an
        error).  In either case, the headers are sent, making the
        interface the same as for send_head().

        zNo permission to list directoryNc*|Sr*)rX)as r<lambda>z9SimpleHTTPRequestHandler.list_directory.<locals>.<lambda>s		r)key
surrogatepasserrorsFr{zDirectory listing for z<!DOCTYPE HTML>z<html lang="en">z<head>z<meta charset="z">z<title>z</title>
</head>z<body>
<h1>z</h1>z	<hr>
<ul>r'@z
<li><a href="z	</a></li>z</ul>
<hr>
</body>
</html>
rsurrogateescaperrztext/html; charset=%sr) rlistdirr*rHrr(sortrr unquoterLUnicodeDecodeErrorrrrgetfilesystemencodingrrrislinkr|rioBytesIOrseekrr5rr>r2re)
rrLlistrdisplaypathenctitlenamefullnamedisplaynamelinknameencodedrs
             rr&z'SimpleHTTPRequestHandler.list_directorysZ	:d##DD			OO$1
3
3
344		
	
		))	***	: ,..ty6E/GGKK!	:	:	: ,..ty99KKK	:k+U;;;'))666	"###	#$$$		*3***+++	35333444	,,,,---	
	?
	?Dw||D$//H%))K(w}}X&&
&"Sj#:w~~h''
)"Sj
HHH|))(1@*BBBB{;e<<<<<>
?
?
?
?	
2333))A,,%%c+<==JLL		q			:=))))@3)FGGG)3s7||+<+<===s!*AA"&B		.B:9B:c|ddd}|ddd}|d}	tj|d}n/#t$r"tj|}YnwxYwtj|}|d}td|}|j
}|D]\}tj
|s|tjtjfvr<tj||}]|r|dz
}|S)	zTranslate a /-separated PATH to the local filename syntax.

        Components that mean special things to the local file system
        (e.g. drive or directory names) are ignored.  (XXX They should
        probably be diagnosed.)

        ?r
r#r'rCrDN)rBr@r"rr rJrK	posixpathnormpathfilterrrrLdirnamecurdirpardirr)rrLtrailing_slashr[words     rrz'SimpleHTTPRequestHandler.translate_pathAsAzz#a  #zz#a  #//44	.<''_'EEDD!	.	.	.<''--DDD	.!$''

3tU##~	,	,Dwt$$
BI0F(F(F7<<d++DD	CKDs!!B)B/.B/c0tj||dS)aCopy all data between two file objects.

        The SOURCE argument is a file object open for reading
        (or anything with a read() method) and the DESTINATION
        argument is a file object open for writing (or
        anything with a write() method).

        The only reason for overriding this would be to change
        the block size or perhaps to replace newlines by CRLF
        -- note however that this the default server uses this
        to copy binary data as well.

        N)shutilcopyfileobj)rsource
outputfiles   rrz!SimpleHTTPRequestHandler.copyfile_s	6:.....rctj|\}}||jvr
|j|S|}||jvr
|j|St	j|\}}|r|SdS)aGuess the type of a file.

        Argument is a PATH (a filename).

        Return value is a string of the form type/subtype,
        usable for a MIME Content-type header.

        The default implementation looks the file's extension
        up in the table self.extensions_map, using application/octet-stream
        as a default; however it would be permissible (if
        slow) to look inside the data to make a better guess.

        r)r^splitextextensions_maprX	mimetypesr')rrLbaseextguess_s      rr'z#SimpleHTTPRequestHandler.guess_typeos&t,,	c$%%%&s++iikk$%%%&s++'--q	L))r)rrrrrrrm_encodings_map_defaultr	rrr
r&rrr'
__classcell__rs@rrrs		#[0N!(%!	//N+)-*******VVVp777r</// *******rrc>|d\}}}tj|}|d}g}|ddD]:}|dkr||r|dkr||;|r<|}|r%|dkr|d}n|dkrd}nd}|rd||f}dd|z|f}d|}|S)a
    Given a URL path, remove extra '/'s and '.' path elements and collapse
    any '..' references and returns a collapsed 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.

    r\r'Nr&z..r(r6)	partitionrr rJrBpoprr)	rLrrquery
path_parts
head_partspart	tail_part	splitpathcollapsed_paths	         r_url_collapse_pathrsE^^C((ND!U<%%DCJJ3B3&&4<<NN
	&dckkt%%%	NN$$		D     		c!!		1HHi/00	sxx
+++Y7IXXi((NrctrtS	ddl}n#t$rYdSwxYw	|ddan>#t$r1dtd|DzaYnwxYwtS)z$Internal routine to get nobody's uidrNr&nobodyrr
c3&K|]}|dV
dS)rNr)r-rs  rr/znobody_uid.<locals>.<genexpr>s&66!1666666r)rpwdImportErrorgetpwnamrmaxgetpwall)rs r
nobody_uidrs




rr7h''*777S66s||~~6666667Ms
##A8A>=A>c@tj|tjS)zTest for executable file.)raccessX_OK)rLs r
executablers
9T27###rcZeZdZdZeedZdZdZdZ	dZ
ddgZd	Zd
Z
dZdS)
rzComplete 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.

    forkrc|r|dS|tjddS)zRServe a POST request.

        This is only implemented for CGI scripts.

        zCan only POST to CGI scriptsN)is_cgirun_cgirHrrlrfs rdo_POSTzCGIHTTPRequestHandler.do_POSTsN;;==	0LLNNNNNOO*.
0
0
0
0
0rc|r|St|S)z-Version of send_head that support CGI scripts)rrrr
rfs rr
zCGIHTTPRequestHandler.send_heads4;;==	<<<>>!+55d;;;rc8t|j}|dd}|dkrA|d||jvr0|d|dz}|dkr|d||jv0|dkr"|d|||dzd}}||f|_dSdS)a3Test 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).

        r'r
rNTF)rrLfindcgi_directoriescgi_info)rrdir_sepheadtails     rrzCGIHTTPRequestHandler.is_cgis,DI66 %%c1--kk.'":d>R"R"R$))#wqy99Gkk.'":d>R"R"RQ;;'1>'!)**3M$D $JDM4urz/cgi-binz/htbinc t|S)z1Test whether argument path is an executable file.)r)rrLs  r
is_executablez#CGIHTTPRequestHandler.is_executables$rcrtj|\}}|dvS)z.Test whether argument path is a Python script.)z.pyz.pyw)rrLrlrX)rrLrrs    r	is_pythonzCGIHTTPRequestHandler.is_pythons.W%%d++
dzz||..rcP|j\}}|dz|z}|dt|dz}|dkr}|d|}||dzd}||}tj|r+||}}|dt|dz}nn|dk}|d\}}}	|d}|dkr|d|||d}}
n|d}}
|dz|
z}||}tj|s%|	tjd|zdStj|s%|	tj
d|zdS||}
|js|
s:||s%|	tj
d	|zdSt#jtj}||d
<|jj|d<d|d
<|j|d<t1|jj|d<|j|d<t6j|}||d<|||d<||d<|	|d<|jd|d<|j d}|r|!}t|dkrddl"}ddl#}|d|d<|d$dkr	|d%d}|&|'d}|!d}t|dkr|d|d<n#|j(tRf$rYnwxYw|j d|j*|d<n|jd|d<|j d}|r||d <|j d!}|r||d"<|j+d#d$}d%,||d&<|j d'}|r||d(<t[d|j+d)g}d*,|}|r||d+<d,D]}|.|d|/tj0d-|1|	2d.d/}|jr|
g}d0|vr|3|ti}|j56t	j7}|dkrt	j8|d\}}tsj9|j:gggddr>|j:;dsn#tsj9|j:gggdd>t	j<|}|r|=d1|dS		t	j>|n#t~$rYnwxYwt	j@|j:Adt	j@|j5Adt	jB|||dS#|jC|jD|jt	jEd2YdSxYwddlF} |g}!||rOtjH}"|"$Id3r|"dd4|"d5dz}"|"d6g|!z}!d0|	vr|!3|	|Jd7| K|!	t|}#n#ttf$rd}#YnwxYw| O|!| jP| jP| jP|8}$|j$d9kr!|#dkr|j:;|#}%nd}%tsj9|j:jQgggddrH|j:jQRdsn(tsj9|j:jQgggddH|$S|%\}&}'|j5T|&|'r|=d:|'|$jUV|$jWV|$jX}(|(r|=d;|(dS|Jd<dS)=zExecute a CGI script.r'r
rNr\r6zNo such CGI script (%r)z#CGI script is not a plain file (%r)z!CGI script is not executable (%r)SERVER_SOFTWARESERVER_NAMEzCGI/1.1GATEWAY_INTERFACESERVER_PROTOCOLSERVER_PORTREQUEST_METHOD	PATH_INFOPATH_TRANSLATEDSCRIPT_NAMEQUERY_STRINGREMOTE_ADDR
authorizationr	AUTH_TYPEbasicascii:REMOTE_USERzcontent-typeCONTENT_TYPEzcontent-lengthCONTENT_LENGTHrefererHTTP_REFERERacceptr,HTTP_ACCEPTz
user-agentHTTP_USER_AGENTcookiez, HTTP_COOKIE)rREMOTE_HOSTrrrrzScript output follows+r=zCGI script exit code rzw.exez-uzcommand: %s)stdinstdoutrenvpostz%szCGI script exit status %#xzCGI script exited OK)Yrrr2rrrLrrwexistsrHrr(r%	FORBIDDENr	have_forkrcopydeepcopyenvironrserverrrJr>rr:rr rJrrSrWrBbase64binasciirXrdecodebytesdecodeErrorUnicodeErrorget_content_typeget_allrr`
setdefaultrr5rrrrrnrorwaitpidselectrQreadwaitstatus_to_exitcoderqsetuidr*dup2r,execvehandle_errorrequest_exit
subprocessrrr"rlist2cmdlinerFr3rDPopenPIPE_sockrecvcommunicaterrr7r
returncode))rdirrestrLinextdirnextrest	scriptdirrrryscript
scriptname
scriptfileispyruqrestrrrlengthrruaco
cookie_strk
decoded_queryrrpidstsexitcodercmdlineinterpnbytespdatarrstatuss)                                         rrzCGIHTTPRequestHandler.run_cgis
M	TSy4IIc3s88A:&&1ff2A2hGAaCDDzH++G44Iw}}Y''
#XTIIc3s88A:..1ff,,a
IIcNN668T!""XDFFDF3Y'
((44
w~~j))	OO$)J6
8
8
8
Fw~~j))	OO$5
B
D
D
D
F~~j))>		%%j11
(7*DFFFmBJ''!%!4!4!6!6![4M#, !%!6 !899M $%%d++!K!%!4!4V!<!<'M#N!03M((99
	B)//11M=!!Q&&''''''''#0#3K  #))++w66	B(5a(8(?(?(H(H
(.(:(:=(I(I(.w&
)6(;(;C(@(@
}--221>q1AC
.%NL9<N++3"&,"?"?"A"AC"&,~">C!!"233	+$*C !,""9--	*")C%%h33 XXf--M
\

l
+
+
	(%'C!"
D$,..x<<
=
=YYr]]
	,!+C
D	"	"ANN1b!!!!:=*ABBB

c3//
>I	98D-''M***\\FJ'))Caxx:c1--SmTZL"b!<<Q?:??1--mTZL"b!<<Q?4S99GNN#E8#E#EFFF

If%%%%D
))++Q///
))++Q///	*dC00000
((t7JKKK






!lG~~j))
3<<>>**7337#CRC[6"##;6F!4.72%u%%%]J,C,CG,L,LMMM
Vz*



  '1(2(2'*	!##A|!!##v--&1**zv..-!1 2BA>>qA
z',,Q//-!1 2BA>>qA
]]400NFFJV$$$
-tV,,,
HNN
HNN\F
9;VDDDDD  !788888sP
AOOO.Z\
Z
\ZA1\;]2```N)rrrrrkrrrbufsizerr
rrrrrrrrrrsF##IH000<<<4"8,O   ///
x9x9x9x9x9rrctj|tjtjd}t	t|\}}}}}||fS)N)typeflags)rgetaddrinfoSOCK_STREAM
AI_PASSIVEnextiter)addressinfosfamilyrproto	canonnamesockaddrs       r_get_best_familyrsS	




E
04DKK/@/@,FD%H8rri@ct||\|_}||_|||5}|jdd\}}d|vrd|dn|}td|d|d|d|d			|n3#t$r&td
tj	dYnwxYwddddS#1swxYwYdS)zmTest the HTTP request handler class.

    This runs an HTTP server on port 8000 (or the port argument).

    Nrr[]zServing HTTP on z port z	 (http://z/) ...z&
Keyboard interrupt received, exiting.r)
raddress_familyrJrgetsocknameprint
serve_foreverKeyboardInterruptrexit)	HandlerClassServerClassprotocolrbindaddrhttpdrurl_hosts	         rtestr!sr(8d'C'C$K$,L!	T<	(	(E\--//3
d"%++;t;;;;4

/t
/
/4
/
/
/
/"&
/
/
/	
	
	
	!!!! 			;<<<HQKKKKK	s6A
C:BC-B?<C>B??CCC__main__z--cgi
store_truezrun as CGI server)actionhelpz-bz--bindADDRESSz.bind to this address (default: all interfaces))metavarr%z-dz--directoryz1serve this directory (default: current directory))defaultr%z-pz
--protocolVERSIONz3conform to this HTTP version (default: %(default)s))r'r(r%rr\z(bind to this port (default: %(default)s))r(rnargsr%c$eZdZfdZdZxZS)DualStackServerctjt5|jtjtjddddn#1swxYwYtS)Nr)	
contextlibsuppress	Exceptionr
setsockoptIPPROTO_IPV6IPV6_V6ONLYrr)rrs rrzDualStackServer.server_binds$Y//
@
@&&');Q@@@
@
@
@
@
@
@
@
@
@
@
@
@
@
@
@77&&(((s1AAAcL||||tjdS)Nr)RequestHandlerClassrr)rrrs   rfinish_requestzDualStackServer.finish_requests4$$Wnd/3~
%
?
?
?
?
?r)rrrrr6rtrus@rr,r,sG	)	)	)	)	)	?	?	?	?	?	?	?rr,)rrrrr)8rr__all__rr.email.utilsrrhttp.clientrNrNrrnrr^rrgrr
rrurllib.parserrrrrrThreadingMixInrStreamRequestHandlerrrrrrrrrr!rargparser.ArgumentParserparseradd_argumentrrF
parse_argsrcgi
handler_classr,rrrrrr<module>rDsd
								















 7	 	 	 	 	 '	 	 	 ,5zqqqqq\>qqqh@*@*@*@*@*5@*@*@*J,,,`



 $$$
C9C9C9C9C94C9C9C9L-(4d.zOOO
$X
$
&
&F
0222
h	9:::mYRY[[<===lI *67773c6777Dx1-

0
?????-???	D"#
Y
YQr