File "server.cpython-36.opt-1.pyc"

Full Path: /home/attunedd/public_html/byp/izo/con7ext_sym404/rintoar.txt/lib64/python3.6/http/__pycache__/server.cpython-36.opt-1.pyc
File size: 31.52 KB
MIME-type: text/x-bytecode.python
Charset: 8 bit

3

\dh@sdZdZddddgZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlmZd	Zd
ZGdddejZGdddejZGd
ddeZddZdaddZ ddZ!GdddeZ"eedddfddZ#e$dkrej%Z&e&j'dddde&j'dd dd!d"d#e&j'd$d%de(d&d'd(e&j)Z*e*j+r~e"Z,neZ,e#e,e*j-e*j.d)dS)*a@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
HTTPServerBaseHTTPRequestHandlerSimpleHTTPRequestHandlerCGIHTTPRequestHandlerN)
HTTPStatusa<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;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-8c@seZdZdZddZdS)rcCs4tjj||jdd\}}tj||_||_dS)z.Override server_bind to store the server name.N)socketserver	TCPServerserver_bindserver_addresssocketZgetfqdnserver_nameserver_port)selfhostportr#/usr/lib64/python3.6/http/server.pyrszHTTPServer.server_bindN)__name__
__module____qualname__Zallow_reuse_addressrrrrrrsc
@seZdZdZdejjdZdeZ	e
ZeZ
dZddZdd	Zd
dZdd
Zd@ddZdAddZdBddZddZddZddZdCddZddZd d!Zd"d#ZdDd$d%Zd&d'Zd(d)d*d+d,d-d.gZdd/d0d1d2d3d4d5d6d7d8d9d:g
Z d;d<Z!d=Z"e#j$j%Z&d>d?e'j(j)DZ*dS)EraHTTP 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/zHTTP/0.9cCsd|_|j|_}d|_t|jd}|jd}||_|j}t	|dkr|\}}}yZ|dddkrjt
|jdd	d	}|jd
}t	|dkrt
t|dt|d	f}Wn*t
tfk
r|j
tjd
|dSX|dkr|jdkrd|_|dkrr|j
tjd|dSn^t	|dkrR|\}}d|_|dkrr|j
tjd|dSn |s\dS|j
tjd|dS||||_|_|_|jjdrd|jjd|_ytjj|j|jd|_Wnrtjjk
r}z|j
tjdt|dSd}~Xn:tjjk
r4}z|j
tjdt|dSd}~XnX|jjdd}	|	jdkrZd|_n |	jdkrz|jdkrzd|_|jjdd}
|
jdkr|jdkr|jdkr|j sdSdS) a'Parse 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, an
        error is sent back.

        NTz
iso-8859-1z
zHTTP//r.rrzBad request version (%r)FzHTTP/1.1zInvalid HTTP version (%s)ZGETzBad HTTP/0.9 request type (%r)zBad request syntax (%r)z//)Z_classz
Line too longzToo many headers
Connectionclosez
keep-aliveZExpectz100-continue)rr)rr)!commanddefault_request_versionrequest_versionclose_connectionstrraw_requestlinerstriprequestlinesplitlen
ValueErrorint
IndexError
send_errorrZBAD_REQUESTprotocol_versionZHTTP_VERSION_NOT_SUPPORTEDpath
startswithlstriphttpclientZ
parse_headersrfileMessageClassheadersZLineTooLongZREQUEST_HEADER_FIELDS_TOO_LARGEZ
HTTPExceptiongetlowerhandle_expect_100)rversionr&wordsrr.Zbase_version_numberZversion_numbererrZconntypeZexpectrrr
parse_requests












z$BaseHTTPRequestHandler.parse_requestcCs|jtj|jdS)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_onlyrZCONTINUEend_headers)rrrrr8nsz(BaseHTTPRequestHandler.handle_expect_100cCsy|jjd|_t|jdkr@d|_d|_d|_|jtj	dS|jsPd|_
dS|js\dSd|j}t||s|jtj
d|jdSt||}||jjWn4tjk
r}z|jd|d|_
dSd}~XnXdS)	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.

        iirNTZdo_zUnsupported method (%r)zRequest timed out: %r)r3readliner$r(r&r!rr,rZREQUEST_URI_TOO_LONGr"r<hasattrNOT_IMPLEMENTEDgetattrwfileflushr
Ztimeout	log_error)rZmnamemethoderrrhandle_one_requests4


z)BaseHTTPRequestHandler.handle_one_requestcCs&d|_|jx|js |jqWdS)z&Handle multiple requests if necessary.TN)r"rH)rrrrhandleszBaseHTTPRequestHandler.handleNcCs
y|j|\}}Wntk
r.d\}}YnX|dkr<|}|dkrH|}|jd|||j|||jddd}|dkr|tjtjtjfkr|j	|t
j|ddt
j|ddd	}|jd
d}|jd|j
|jd
tt||j|jdko|r|jj|dS)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.

        ???Nzcode %d, message %srrF)quote)codemessageexplainzUTF-8replacezContent-TypezContent-LengthZHEAD)rJrJ)	responsesKeyErrorrE
send_responsesend_headerrZ
NO_CONTENTZ
RESET_CONTENTZNOT_MODIFIEDerror_message_formathtmlescapeencodeerror_content_typer#r(r>rrCwrite)rrMrNrOZshortmsgZlongmsgZbodyZcontentrrrr,s4
z!BaseHTTPRequestHandler.send_errorcCs:|j||j|||jd|j|jd|jdS)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.

        ZServerZDateN)log_requestr=rTversion_stringdate_time_string)rrMrNrrrrSs
z$BaseHTTPRequestHandler.send_responsecCsd|jdkr`|dkr0||jkr,|j|d}nd}t|ds@g|_|jjd|j||fjdddS)	zSend the response header only.zHTTP/0.9Nrr_headers_bufferz
%s %d %s
zlatin-1strict)r!rQr@r^appendr-rX)rrMrNrrrr=s


z)BaseHTTPRequestHandler.send_response_onlycCsl|jdkr6t|dsg|_|jjd||fjdd|jdkrh|jdkrVd|_n|jd	krhd
|_dS)z)Send a MIME header to the headers buffer.zHTTP/0.9r^z%s: %s
zlatin-1r_Z
connectionrTz
keep-aliveFN)r!r@r^r`rXr7r")rkeywordvaluerrrrTs

z"BaseHTTPRequestHandler.send_headercCs"|jdkr|jjd|jdS)z,Send the blank line ending the MIME headers.zHTTP/0.9s
N)r!r^r`
flush_headers)rrrrr>s
z"BaseHTTPRequestHandler.end_headerscCs(t|dr$|jjdj|jg|_dS)Nr^)r@rCrZjoinr^)rrrrrcs
z$BaseHTTPRequestHandler.flush_headers-cCs.t|tr|j}|jd|jt|t|dS)zNLog an accepted request.

        This is called by send_response().

        z
"%s" %s %sN)
isinstancerrblog_messager&r#)rrMsizerrrr[s
z"BaseHTTPRequestHandler.log_requestcGs|j|f|dS)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)rh)rformatargsrrrrE!sz BaseHTTPRequestHandler.log_errorcGs&tjjd|j|j||fdS)aLog 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.

        z%s - - [%s] %s
N)sysstderrrZaddress_stringlog_date_time_string)rrjrkrrrrh/sz"BaseHTTPRequestHandler.log_messagecCs|jd|jS)z*Return the server software version string. )server_versionsys_version)rrrrr\Esz%BaseHTTPRequestHandler.version_stringcCs |dkrtj}tjj|ddS)z@Return the current date and time formatted for a message header.NT)Zusegmt)timeemailZutilsZ
formatdate)rZ	timestamprrrr]Isz'BaseHTTPRequestHandler.date_time_stringc	CsBtj}tj|\	}}}}}}}}	}
d||j|||||f}|S)z.Return the current time formatted for logging.z%02d/%3s/%04d %02d:%02d:%02d)rsZ	localtime	monthname)rZnowZyearZmonthZdayZhhZmmZssxyzsrrrroOs
z+BaseHTTPRequestHandler.log_date_time_stringZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDeccCs
|jdS)zReturn the client address.r)client_address)rrrrrn]sz%BaseHTTPRequestHandler.address_stringzHTTP/1.0cCsi|]}|j|jf|qSr)phraseZdescription).0vrrr
<dictcomp>lsz!BaseHTTPRequestHandler.<dictcomp>)NN)N)N)rfrf)N)+rrr__doc__rlr9r'rr__version__rqDEFAULT_ERROR_MESSAGErUDEFAULT_ERROR_CONTENT_TYPErYr r<r8rHrIr,rSr=rTr>rcr[rErhr\r]roZweekdaynamerurnr-r1r2ZHTTPMessager4r__members__valuesrQrrrrrs>fg%
5



	c@s|eZdZdZdeZddZddZddZd	d
Z	ddZ
d
dZddZe
jsZe
je
jjZejddddddS)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/c
Cs.|j}|r*z|j||jWd|jXdS)zServe a GET request.N)	send_headcopyfilerCr)rfrrrdo_GETs
zSimpleHTTPRequestHandler.do_GETcCs|j}|r|jdS)zServe a HEAD request.N)rr)rrrrrdo_HEADsz SimpleHTTPRequestHandler.do_HEADc	Csx|j|j}d}tjj|rtjj|j}|jjds|jt	j
|d|d|dd|d|df}tjj|}|jd||j
dSx6dD]$}tjj||}tjj|r|}PqW|j|S|j|}yt|d}Wn$tk
r|jt	jddSXyZ|jt	j|jd
|tj|j}|jdt|d|jd|j|j|j
|S|jYnXdS)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.

        NrrrrrZLocation
index.html	index.htmrbzFile not foundzContent-typezContent-Lengthz
Last-Modified)rr)translate_pathr.osisdirurllibparseZurlsplitendswithrSrZMOVED_PERMANENTLYZ
urlunsplitrTr>reexistslist_directory
guess_typeopenOSErrorr,	NOT_FOUNDOKfstatfilenor#r]st_mtimer)	rr.rpartsZ	new_partsZnew_urlindexZctypeZfsrrrrsF


z"SimpleHTTPRequestHandler.send_headc
Csytj|}Wn"tk
r0|jtjddSX|jdddg}ytjj	|j
dd}Wn tk
r|tjj	|}YnXtj
|dd	}tj}d
|}|jd|jd|jd
||jd||jd||jdx~|D]v}tj
j||}|}	}
tj
j|r"|d}	|d}
tj
j|r8|d}	|jdtjj|
ddtj
|	dd	fqW|jddj|j|d}tj}|j||jd|jtj|jdd||jdtt||j|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 directoryNcSs|jS)N)r7)arrr<lambda>sz9SimpleHTTPRequestHandler.list_directory.<locals>.<lambda>)key
surrogatepass)errorsF)rLzDirectory listing for %szZ<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">z
<html>
<head>z@<meta http-equiv="Content-Type" content="text/html; charset=%s">z<title>%s</title>
</head>z<body>
<h1>%s</h1>z	<hr>
<ul>r@z<li><a href="%s">%s</a></li>z</ul>
<hr>
</body>
</html>

surrogateescaperzContent-typeztext/html; charset=%szContent-Length) rlistdirrr,rrsortrrunquoter.UnicodeDecodeErrorrVrWrlgetfilesystemencodingr`rerislinkrLrXioBytesIOrZseekrSrrTr#r(r>)
rr.listrZdisplaypathenctitlenamefullnameZdisplaynameZlinknameZencodedrrrrrs\







z'SimpleHTTPRequestHandler.list_directorycCs|jddd}|jddd}|jjd}ytjj|dd}Wn tk
rbtjj|}YnXtj|}|jd}t	d|}t
j}x8|D]0}t
jj
|s|t
jt
jfkrqt
jj||}qW|r|d7}|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.)

        ?rr#rr)rN)r'r%rrrrr	posixpathnormpathfilterrgetcwdr.dirnamecurdirpardirre)rr.Ztrailing_slashr:Zwordrrrrs$	



z'SimpleHTTPRequestHandler.translate_pathcCstj||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)shutilZcopyfileobj)rsourceZ
outputfilerrrrsz!SimpleHTTPRequestHandler.copyfilecCsLtj|\}}||jkr"|j|S|j}||jkr>|j|S|jdSdS)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.

        rN)rsplitextextensions_mapr7)rr.baseZextrrrr)s



z#SimpleHTTPRequestHandler.guess_typezapplication/octet-streamz
text/plain)rz.pyz.cz.hN)rrrrrrqrrrrrrr	mimetypesZinitedZinitZ	types_mapcopyrupdaterrrrrrs"	1:
c	Cs|jd\}}}tjj|}|jd}g}x<|ddD],}|dkrN|jq8|r8|dkr8|j|q8W|r|j}|r|dkr|jd}q|dkrd}nd}|rdj||f}ddj||f}dj|}|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.

    rrNrz..rr)	partitionrrrr'popr`re)	r._query
path_partsZ
head_partspartZ	tail_partZ	splitpathcollapsed_pathrrr_url_collapse_pathNs.


rcCsptrtSyddl}Wntk
r(dSXy|jddaWn.tk
rjdtdd|jDaYnXtS)	z$Internal routine to get nobody's uidrNrnobodyrcss|]}|dVqdS)rNr)r|rvrrr	<genexpr>sznobody_uid.<locals>.<genexpr>r)rpwdImportErrorgetpwnamrRmaxZgetpwall)rrrr
nobody_uids rcCstj|tjS)zTest for executable file.)raccessX_OK)r.rrr
executablesrc@sVeZdZdZeedZdZddZddZ	dd	Z
d
dgZdd
ZddZ
ddZdS)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.

    forkrcCs$|jr|jn|jtjddS)zRServe a POST request.

        This is only implemented for CGI scripts.

        zCan only POST to CGI scriptsN)is_cgirun_cgir,rrA)rrrrdo_POSTs

zCGIHTTPRequestHandler.do_POSTcCs|jr|jStj|SdS)z-Version of send_head that support CGI scriptsN)rrrr)rrrrrszCGIHTTPRequestHandler.send_headcCsPt|j}|jdd}|d|||dd}}||jkrL||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).

        rrNTF)rr.findcgi_directoriescgi_info)rrZdir_sepheadtailrrrrs


zCGIHTTPRequestHandler.is_cgiz/cgi-binz/htbincCst|S)z1Test whether argument path is an executable file.)r)rr.rrr
is_executablesz#CGIHTTPRequestHandler.is_executablecCstjj|\}}|jdkS)z.Test whether argument path is a Python script..py.pyw)rr)rr.rr7)rr.rrrrr	is_pythonszCGIHTTPRequestHandler.is_pythonc)Cs|j\}}|d|}|jdt|d}x`|dkr|d|}||dd}|j|}tjj|r||}}|jdt|d}q,Pq,W|jd\}}}	|jd}|dkr|d|||d}
}n
|d}
}|d|
}|j|}tjj|s|j	t
jd|dStjj|s2|j	t
j
d|dS|j|}
|jsL|
rn|j|sn|j	t
j
d	|dStjtj}|j|d
<|jj|d<d|d
<|j|d<t|jj|d<|j|d<tjj|}||d<|j||d<||d<|	r|	|d<|jd|d<|jj d}|r|j!}t|dkrddl"}ddl#}|d|d<|dj$dkry"|dj%d}|j&|j'd}Wn|j(t)fk
rYn&X|j!d}t|dkr|d|d<|jj ddkr|jj*|d<n|jd|d<|jj d}|r||d <|jj d!}|r"||d"<g}xN|jj+d#D]>}|ddd$krZ|j,|j-n||d%dj!d&}q4Wd&j.||d'<|jj d(}|r||d)<t/d|jj0d*g}d+j.|}|r||d,<xd=D]}|j1|dqW|j2t
j3d.|j4|	j5d/d0}|jr.|
g}d1|kr*|j,|t6}|j7j8tj9}|dkrtj:|d\}}x0t;j;|j<gggddr|j<j=ds^Pq^W|r|j>d2|dSy\ytj?|Wnt@k
rYnXtjA|j<jBdtjA|j7jBdtjC|||Wn(|jjD|jE|jtjFd3YnXnddlG} |g}!|j|rtHjI}"|"j$jJd4rv|"dd>|"d?d}"|"d7g|!}!d1|	kr|!j,|	|jKd8| jL|!ytM|}#WntNtOfk
rd}#YnX| jP|!| jQ| jQ| jQ|d9}$|jj$d:kr|#dkr|j<j=|#}%nd}%x4t;j;|j<jRgggddrN|j<jRjSdsPqW|$jT|%\}&}'|j7jU|&|'r||j>d;|'|$jVjW|$jXjW|$jY}(|(r|j>d2|(n
|jKd<dS)@zExecute a CGI script.rrrNrrzNo such CGI script (%r)z#CGI script is not a plain file (%r)z!CGI script is not executable (%r)ZSERVER_SOFTWAREZSERVER_NAMEzCGI/1.1ZGATEWAY_INTERFACEZSERVER_PROTOCOLZSERVER_PORTZREQUEST_METHODZ	PATH_INFOZPATH_TRANSLATEDZSCRIPT_NAMEQUERY_STRINGZREMOTE_ADDR
authorizationrZ	AUTH_TYPEZbasicascii:ZREMOTE_USERzcontent-typeZCONTENT_TYPEzcontent-lengthCONTENT_LENGTHrefererHTTP_REFERERacceptz	

 ,ZHTTP_ACCEPTz
user-agentHTTP_USER_AGENTZcookiez, HTTP_COOKIEREMOTE_HOSTzScript output follows+rp=zCGI script exit status %#xzw.exerrz-uzcommand: %s)stdinstdoutrmenvZpostz%szCGI script exited OK)rrrrrr)Zrrr(rrr.rrrr,rrisfileZ	FORBIDDENr	have_forkrrdeepcopyenvironr\Zserverrr-r#rrrrrrzr5r6r'base64binasciir7rXZdecodebytesdecodeErrorUnicodeErrorZget_content_typeZgetallmatchingheadersr`striprerZget_all
setdefaultrSrrcrPrrCrDrwaitpidselectr3readrEsetuidrdup2rexecveZhandle_errorZrequest_exit
subprocessrlrrrhZlist2cmdliner*	TypeErrorr)PopenPIPEZ_sockZrecvZcommunicaterZrmrr
returncode))rdirrestr.iZnextdirZnextrestZ	scriptdirrrZscriptZ
scriptnameZ
scriptfileZispyrZuqrestrrrZlengthrrlineZuacoZ
cookie_strkZ
decoded_queryrkrpidstsrZcmdlineZinterpnbytespdatarrmZstatusrrrrs4

























zCGIHTTPRequestHandler.run_cgiN)rrrrr@rrZrbufsizerrrrrrrrrrrrs
zHTTP/1.0i@rc	Cs||f}||_|||b}|jj}d}t|j|d|ddy|jWn&tk
rttdtjdYnXWdQRXdS)zmTest the HTTP request handler class.

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

    z>Serving HTTP on {host} port {port} (http://{host}:{port}/) ...rr)rrz&
Keyboard interrupt received, exiting.N)	r-r
ZgetsocknameprintrjZ
serve_foreverKeyboardInterruptrlexit)	HandlerClassZServerClassZprotocolrbindrZhttpdZsaZ
serve_messagerrrtests
r%__main__z--cgi
store_truezRun as CGI Server)actionhelpz--bindz-bZADDRESSz8Specify alternate bind address [default: all interfaces])defaultmetavarr)rZstorerz&Specify alternate port [default: 8000])r(r*typenargsr))r#rr$)/rr__all__Zemail.utilsrtrVZhttp.clientr1rrrrr
rr
r	rlrsZurllib.parserrargparserrrr
rZStreamRequestHandlerrrrrrrrr%rArgumentParserparseradd_argumentr*
parse_argsrkZcgiZ
handler_classrr$rrrr<module> sj3g]0