X&_c @`shdZddlmZmZmZmZddlmZddlTdZ ddgZ ddl m Z dd l mZdd lmZdd l mZdd lZdd lZdd lZdd lZdd lZdd lZdd lZdd lZdd lZdd lZdd lZd ZdZ dZ!dej"fdYZ#dej$fdYZ%de%fdYZ&dZ'e(a)dZ*dZ+de&fdYZ,e%e#dddZ-e.dkrdej/Z0e0j1dd d!d"d#e0j1d$d d%d&dd'e2d(d)d"d*e0j3Z4e4j5rKe-d+e,d,e4j6ne-d+e&d,e4j6nd S(-uQHTTP server classes. From Python 3.3 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 i(tabsolute_importtdivisiontprint_functiontunicode_literals(tutils(t*u0.6u HTTPServeruBaseHTTPRequestHandler(thtml(tclient(tparse(t socketserverNu Error response

Error response

Error code: %(code)d

Message: %(message)s.

Error code explanation: %(code)s - %(explain)s.

utext/html;charset=utf-8cC`s(|jddjddjddS(Nu&u&uu>(treplace(R((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyt _quote_htmlst HTTPServercB`seZdZdZRS(icC`sHtjj||jjd \}}tj||_||_dS(u.Override server_bind to store the server name.iN(R t TCPServert server_bindtsockett getsocknametgetfqdnt server_namet server_port(tselfthosttport((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyRs(t__name__t __module__tallow_reuse_addressR(((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyR stBaseHTTPRequestHandlerc B`s}eZdZdejjdZdeZe Z e Z dZ dZdZdZdZdd Zdd Zdd Zd Zd ZdZdddZdZdZdZddZdZdddddddgZddddd d!d"d#d$d%d&d'd(g Z d)Z!d*Z"e#j$Z%i,dd-6dd06dd36dd66dd96dd<6dd?6ddB6ddE6ddH6ddK6ddN6ddQ6ddT6ddW6ddY6dd\6dd_6ddb6dde6ddh6ddk6ddn6ddq6ddt6ddw6ddz6dd}6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6dd6Z&RS(uHTTP 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 where is a (case-sensitive) keyword such as GET or POST, is a string containing path information for the request, and should be the string "HTTP/1.0" or "HTTP/1.1". 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 (i.e. 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 where is the protocol version ("HTTP/1.0" or "HTTP/1.1"), is a 3-digit response code indicating success or failure of the request, and 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 (). 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: / where and should be registered MIME types, e.g. "text/html" or "text/plain". uPython/iu BaseHTTP/uHTTP/0.9c C`sd|_|j|_}d|_t|jd}|jd}||_|j }t |dkr|\}}}|d dkr|j dd|t Syd|j d dd}|j d }t |d krt nt|d t|df}Wn,t tfk r3|j dd|t SX|dkr[|jd kr[d |_n|dkr|j dd|t Snpt |d kr|\}}d|_|dkr|j dd|t Sn"|st S|j dd|t S||||_|_|_y"tj|jd|j|_Wn%tjk rX|j ddt SX|jjdd}|jdkrd|_n-|jdkr|jd krd |_n|jjdd} | jdkr|jd kr|jd kr|jst SntS(u'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. iu iso-8859-1u iiuHTTP/iuBad request version (%r)u/u.iiuHTTP/1.1iuInvalid HTTP Version (%s)uGETuBad HTTP/0.9 request type (%r)uBad request syntax (%r)t_classu Line too longu Connectionuucloseu keep-aliveuExpectu 100-continueN(ii(ii(tNonetcommandtdefault_request_versiontrequest_versiontclose_connectiontstrtraw_requestlinetrstript requestlinetsplittlent send_errortFalset ValueErrortintt IndexErrortprotocol_versiontpatht http_clientt parse_headerstrfilet MessageClasstheaderst LineTooLongtgettlowerthandle_expect_100tTrue( RtversionR$twordsRR-tbase_version_numbertversion_numbertconntypetexpect((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyt parse_request st     $            cC`s|jd|jtS(u7Decide 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. id(tsend_response_onlyt flush_headersR7(R((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyR6]s  cC`sy|jjd|_t|jdkrYd|_d|_d|_|jddS|jsod|_dS|j sdSd|j}t ||s|jdd |jdSt ||}||j j Wn0tjk r }|jd |d|_dSXdS( uHandle 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. iiuiNiudo_iuUnsupported method (%r)uRequest timed out: %r(R0treadlineR"R&R$RRR'R R>thasattrtgetattrtwfiletflushRttimeoutt log_error(Rtmnametmethodte((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pythandle_one_requestos0         cC`s1d|_|jx|js,|jqWdS(u&Handle multiple requests if necessary.iN(R RK(R((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pythandles   cC`sy|j|\}}Wntk r6d\}}nX|dkrL|}n|}|jd|||ji|d6t|d6|d6}|j|||jd|j|jdd|j |j d kr|d kr|dkr|j j |j d dndS(uSend and log an error reply. Arguments are the error code, and a detailed message. The detailed message defaults to the short 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. u???ucode %d, message %sucodeumessageuexplainu Content-Typeu ConnectionucloseuHEADiii0uUTF-8ureplaceN(u???u???(ii0(t responsestKeyErrorRRGterror_message_formatR t send_responset send_headerterror_content_typet end_headersRRDtwritetencode(Rtcodetmessagetshortmsgtlongmsgtexplaintcontent((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyR's    " 'cC`sM|j||j|||jd|j|jd|jdS(uAdd 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. uServeruDateN(t log_requestR?RQtversion_stringtdate_time_string(RRVRW((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyRPs cC`s|dkr8||jkr/|j|d}q8d}n|jdkrt|dsbg|_n|jjd|j||fjddndS( uSend the response header only.iuuHTTP/0.9u_headers_bufferu %s %d %s ulatin-1ustrictN(RRMRRBt_headers_buffertappendR,RU(RRVRW((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyR?s    cC`s|jdkrSt|ds*g|_n|jjd||fjddn|jdkr|jdkrd|_q|jd krd |_qnd S( u)Send a MIME header to the headers buffer.uHTTP/0.9u_headers_bufferu%s: %s ulatin-1ustrictu connectionucloseiu keep-aliveiN(RRBR_R`RUR5R (Rtkeywordtvalue((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyRQs    cC`s0|jdkr,|jjd|jndS(u,Send the blank line ending the MIME headers.uHTTP/0.9s N(RR_R`R@(R((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyRSscC`s;t|dr7|jjdj|jg|_ndS(Nu_headers_buffert(RBRDRTtjoinR_(R((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyR@su-cC`s)|jd|jt|t|dS(uNLog an accepted request. This is called by send_response(). u "%s" %s %sN(t log_messageR$R!(RRVtsize((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyR\s cG`s|j||dS(uLog 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(Re(Rtformattargs((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyRGs cG`s1tjjd|j|j||fdS(uLog 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. u%s - - [%s] %s N(tsyststderrRTtaddress_stringtlog_date_time_string(RRgRh((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyRes   cC`s|jd|jS(u*Return the server software version string.u (tserver_versiont sys_version(R((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyR]sc C`sv|dkrtj}ntj|\ }}}}}}}} } d|j|||j|||||f} | S(u@Return the current date and time formatted for a message header.u#%s, %02d %3s %4d %02d:%02d:%02d GMTN(Rttimetgmtimet weekdaynamet monthname( Rt timestamptyeartmonthtdaythhtmmtsstwdtytzts((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyR^s * c C`s]tj}tj|\ }}}}}}}} } d||j|||||f} | S(u.Return the current time formatted for logging.u%02d/%3s/%04d %02d:%02d:%02d(Rot localtimeRr( RtnowRtRuRvRwRxRytxR{R|R}((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyRl*s  * uMonuTueuWeduThuuFriuSatuSunuJanuFebuMaruApruMayuJunuJuluAuguSepuOctuNovuDeccC`s |jdS(uReturn the client address.i(tclient_address(R((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyRk8suHTTP/1.0uContinueu!Request received, please continueiduSwitching Protocolsu.Switching to new protocol; obey Upgrade headerieuOKu#Request fulfilled, document followsiuCreateduDocument created, URL followsiuAcceptedu/Request accepted, processing continues off-lineiuNon-Authoritative InformationuRequest fulfilled from cacheiu No Contentu"Request fulfilled, nothing followsiu Reset Contentu#Clear input form for further input.iuPartial ContentuPartial content follows.iuMultiple Choicesu,Object has several resources -- see URI listi,uMoved Permanentlyu(Object moved permanently -- see URI listi-uFoundu(Object moved temporarily -- see URI listi.u See Otheru'Object moved -- see Method and URL listi/u Not Modifiedu)Document has not changed since given timei0u Use ProxyuAYou must use proxy specified in Location to access this resource.i1uTemporary Redirecti3u Bad Requestu(Bad request syntax or unsupported methodiu Unauthorizedu*No permission -- see authorization schemesiuPayment Requiredu"No payment -- see charging schemesiu Forbiddenu0Request forbidden -- authorization will not helpiu Not FounduNothing matches the given URIiuMethod Not Allowedu.Specified method is invalid for this resource.iuNot Acceptableu&URI not available in preferred format.iuProxy Authentication Requiredu8You must authenticate with this proxy before proceeding.iuRequest Timeoutu#Request timed out; try again later.iuConflictuRequest conflict.iuGoneu6URI no longer exists and has been permanently removed.iuLength Requiredu#Client must specify Content-Length.iuPrecondition Failedu!Precondition in headers is false.iuRequest Entity Too LargeuEntity is too large.iuRequest-URI Too LonguURI is too long.iuUnsupported Media Typeu"Entity body in unsupported format.iuRequested Range Not SatisfiableuCannot satisfy request range.iuExpectation Failedu(Expect condition could not be satisfied.iuPrecondition Requiredu9The origin server requires the request to be conditional.iuToo Many RequestsuPThe user has sent too many requests in a given amount of time ("rate limiting").iuRequest Header Fields Too LargeuWThe server is unwilling to process the request because its header fields are too large.iuInternal Server ErroruServer got itself in troubleiuNot Implementedu&Server does not support this operationiu Bad Gatewayu,Invalid responses from another server/proxy.iuService Unavailableu8The server cannot process the request due to a high loadiuGateway Timeoutu4The gateway server did not receive a timely responseiuHTTP Version Not SupporteduCannot fulfill request.iuNetwork Authentication Requiredu8The client needs to authenticate to gain network access.iN(uContinueu!Request received, please continue(uSwitching Protocolsu.Switching to new protocol; obey Upgrade header(uOKu#Request fulfilled, document follows(uCreateduDocument created, URL follows(uAcceptedu/Request accepted, processing continues off-line(uNon-Authoritative InformationuRequest fulfilled from cache(u No Contentu"Request fulfilled, nothing follows(u Reset Contentu#Clear input form for further input.(uPartial ContentuPartial content follows.(uMultiple Choicesu,Object has several resources -- see URI list(uMoved Permanentlyu(Object moved permanently -- see URI list(uFoundu(Object moved temporarily -- see URI list(u See Otheru'Object moved -- see Method and URL list(u Not Modifiedu)Document has not changed since given time(u Use ProxyuAYou must use proxy specified in Location to access this resource.(uTemporary Redirectu(Object moved temporarily -- see URI list(u Bad Requestu(Bad request syntax or unsupported method(u Unauthorizedu*No permission -- see authorization schemes(uPayment Requiredu"No payment -- see charging schemes(u Forbiddenu0Request forbidden -- authorization will not help(u Not FounduNothing matches the given URI(uMethod Not Allowedu.Specified method is invalid for this resource.(uNot Acceptableu&URI not available in preferred format.(uProxy Authentication Requiredu8You must authenticate with this proxy before proceeding.(uRequest Timeoutu#Request timed out; try again later.(uConflictuRequest conflict.(uGoneu6URI no longer exists and has been permanently removed.(uLength Requiredu#Client must specify Content-Length.(uPrecondition Failedu!Precondition in headers is false.(uRequest Entity Too LargeuEntity is too large.(uRequest-URI Too LonguURI is too long.(uUnsupported Media Typeu"Entity body in unsupported format.(uRequested Range Not SatisfiableuCannot satisfy request range.(uExpectation Failedu(Expect condition could not be satisfied.(uPrecondition Requiredu9The origin server requires the request to be conditional.(uToo Many RequestsuPThe user has sent too many requests in a given amount of time ("rate limiting").(uRequest Header Fields Too LargeuWThe server is unwilling to process the request because its header fields are too large.(uInternal Server ErroruServer got itself in trouble(uNot Implementedu&Server does not support this operation(u Bad Gatewayu,Invalid responses from another server/proxy.(uService Unavailableu8The server cannot process the request due to a high load(uGateway Timeoutu4The gateway server did not receive a timely response(uHTTP Version Not SupporteduCannot fulfill request.(uNetwork Authentication Requiredu8The client needs to authenticate to gain network access.('RRt__doc__RiR8R%Rnt __version__RmtDEFAULT_ERROR_MESSAGEROtDEFAULT_ERROR_CONTENT_TYPERRRR>R6RKRLRR'RPR?RQRSR@R\RGReR]R^RlRqRrRkR,R.t HTTPMessageR1RM(((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyRsf  Q  #            tSimpleHTTPRequestHandlercB`seZdZdeZdZdZdZdZdZ dZ dZ e j ske jne jjZejid d 6d d 6d d 6d d6RS(uWSimple 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. u SimpleHTTP/cC`s6|j}|r2|j||j|jndS(uServe a GET request.N(t send_headtcopyfileRDtclose(Rtf((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pytdo_GETs cC`s#|j}|r|jndS(uServe a HEAD request.N(RR(RR((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pytdo_HEADs cC`s}|j|j}d}tjj|r|jjdsn|jd|jd|jd|jdSxOdD]7}tjj ||}tjj |ru|}PququW|j |Sn|j |}yt |d}Wn"tk r|jdddSX|jd |jd |tj|j}|jd t|d |jd |j|j|j|S(u{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. u/i-uLocationu index.htmlu index.htmurbiuFile not foundiu Content-typeuContent-Lengthiu Last-ModifiedN(u index.htmlu index.htm(ttranslate_pathR-RtostisdirtendswithRPRQRSRdtexiststlist_directoryt guess_typetopentIOErrorR'tfstattfilenoR!R^tst_mtime(RR-Rtindextctypetfs((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyRs6       c C`sytj|}Wn%tjk r:|jdddSX|jddg}tjtj |j }t j }d|}|j d|j d|j d||j d ||j d ||j d x|D]}tj j||}|} } tj j|r4|d } |d } ntj j|rS|d } n|j dtj| tj| fqW|j ddj|j|} tj} | j| | jd|jd|jdd||jdtt| |j| S(uHelper 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(). iuNo permission to list directorytkeycS`s |jS(N(R5(ta((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pytRcuDirectory listing for %suZu u@u%s u

%s

u
    u/u@u
  • %s
  • u

u iiu Content-typeutext/html; charset=%suContent-LengthN(RtlistdirterrorR'RtsortRtescapet urllib_parsetunquoteR-RitgetfilesystemencodingR`RdRtislinktquoteRUtiotBytesIORTtseekRPRQR!R&RS( RR-tlisttrt displaypathtencttitletnametfullnamet displaynametlinknametencodedR((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyRsJ            $      cC`s|jddd}|jddd}tjtj|}|jd}td|}tj}xq|D]i}tj j |\}}tj j|\}}|tj tj fkrquntj j ||}quW|S(uTranslate 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.) u?iiu#u/N(R%t posixpathtnormpathRRtfilterRRtgetcwdR-t splitdrivetcurdirtpardirRd(RR-R9twordtdrivethead((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyR s   cC`stj||dS(uCopy 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(tshutilt copyfileobj(Rtsourcet outputfile((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyR#scC`sdtj|\}}||jkr/|j|S|j}||jkrU|j|S|jdSdS(uGuess 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. uN(Rtsplitexttextensions_mapR5(RR-tbasetext((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyR3s   uapplication/octet-streamuu text/plainu.pyu.cu.h(RRRRRmRRRRRRRt mimetypestinitedtinitt types_maptcopyRtupdate(((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyRs"     ) 4      cC`s|jd}g}xM|d D]A}|dkr?|jq |r |dkr |j|q q W|r|j}|r|dkr|jd}q|dkrd}qqnd}ddj||f}dj|}|S(u` 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: A tuple of (head, tail) where tail is everything after the final / and head is everything before it. Head will always start with a '/' and, if it contains anything else, never have a trailing '/'. Raises: IndexError if too many '..' occur within the path. u/iu..u.u(R%tpopR`Rd(R-t path_partst head_partstpartt tail_partt splitpathtcollapsed_path((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyt_url_collapse_pathXs&       cC`s~tr tSyddl}Wntk r.dSXy|jddaWn1tk rydtd|jDanXtS(u$Internal routine to get nobody's uidiNiunobodyiics`s|]}|dVqdS(iN((t.0R((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pys s(tnobodytpwdt ImportErrortgetpwnamRNtmaxtgetpwall(R((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyt nobody_uids  $cC`stj|tjS(uTest for executable file.(RtaccesstX_OK(R-((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyt executablestCGIHTTPRequestHandlercB`seeZdZeedZdZdZdZdZ ddgZ dZ d Z d Z RS( uComplete 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. uforkicC`s-|jr|jn|jdddS(uRServe a POST request. This is only implemented for CGI scripts. iuCan only POST to CGI scriptsN(tis_cgitrun_cgiR'(R((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pytdo_POSTs  cC`s'|jr|jStj|SdS(u-Version of send_head that support CGI scriptsN(RRRR(R((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyRs  cC`s`t|j}|jdd}|| ||d}}||jkr\||f|_tStS(u3Test 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). u/i(RR-tfindtcgi_directoriestcgi_infoR7R((RRtdir_sepRttail((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyRsu/cgi-binu/htbincC`s t|S(u1Test whether argument path is an executable file.(R(RR-((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyt is_executablescC`s(tjj|\}}|jdkS(u.Test whether argument path is a Python script.u.pyu.pyw(u.pyu.pyw(RR-RR5(RR-RR((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyt is_pythonsc( C`s|j}|j\}}|jdt|d}xv|dkr|| }||d}|j|}tjj|r||}}|jdt|d}q7Pq7W|jd}|dkr|| ||d}}nd}|jd}|dkr|| ||} }n |d} }|d| } |j| } tjj| sq|j dd| dStjj | s|j d d | dS|j | } |j s| r|j | s|j d d | dSntjtj} |j| d <|jj| d |Wntj?k ronXtj@|j;jAdtj@|j6jAdtjB| || Wq|jjC|jD|jtjEd6qXnddlF}| g} |j | rStGjH}!|!j jId7r@|!d8 |!d9}!n|!d:g| } nd4|kro| j,|n|jJd;|jK| ytL|}"WntMtNfk rd}"nX|jO| d<|jPd=|jPd>|jPd?| }#|jj d@kr|"dkr|j;j<|"}$nd}$xBt:j:|j;jQgggddrh|j;jQjRds'Pq'q'W|#jS|$\}%}&|j6jT|%|&r|j=dA|&n|#jUjV|#jWjV|#jX}'|'r|j=d5|'n |jJdBdS(DuExecute a CGI script.u/iiu?uiuNo such CGI script (%r)Niu#CGI script is not a plain file (%r)u!CGI script is not executable (%r)uSERVER_SOFTWAREu SERVER_NAMEuCGI/1.1uGATEWAY_INTERFACEuSERVER_PROTOCOLu SERVER_PORTuREQUEST_METHODu PATH_INFOuPATH_TRANSLATEDu SCRIPT_NAMEu QUERY_STRINGu REMOTE_ADDRu authorizationiu AUTH_TYPEubasicuasciiu:u REMOTE_USERu content-typeu CONTENT_TYPEucontent-lengthuCONTENT_LENGTHurefereru HTTP_REFERERuacceptu iu,u HTTP_ACCEPTu user-agentuHTTP_USER_AGENTucookieu, u HTTP_COOKIEu REMOTE_HOSTiuScript output followsu+u u=uCGI script exit status %#xiuw.exeiiu-uu command: %ststdintstdoutRjtenvupostu%suCGI script exited OK(u QUERY_STRINGu REMOTE_HOSTuCONTENT_LENGTHuHTTP_USER_AGENTu HTTP_COOKIEu HTTP_REFERER(YR-RRR&RRRtrfindRR'tisfileRt have_forkRRtdeepcopytenvironR]tserverRR,R!RRRRRR2R4R%tbase64tbinasciiR5RURtPY3t decodebytestdecodet decodestringtErrort UnicodeErrorRtget_content_typetgetallmatchingheadersR`tstripRdRtget_allt setdefaultRPR@R RRDREtforktwaitpidtselectR0treadRGtsetuidRtdup2Rtexecvet handle_errortrequestt_exitt subprocessRiRRRet list2cmdlineR*t TypeErrorR)tPopentPIPEt_socktrecvt communicateRTRjRRt returncode((RR-tdirtresttitnextdirtnextrestt scriptdirtquerytscriptt scriptnamet scriptfiletispyRtuqrestt authorizationRRtlengthtreferertaccepttlinetuatcot cookie_strtkt decoded_queryRhRtpidtstsR tcmdlinetinterptnbytestptdataRRjtstatus((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyRs8                               %          !(   (RRRRBRRtrbufsizeRRRRRRR(((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyRs     uHTTP/1.0i@cC`sd|f}||_|||}|jj}td|dd|ddy|jWn2tk rtd|jtjdnXdS( uTest the HTTP request handler class. This runs an HTTP server on port 8000 (or the first command line argument). uuServing HTTP oniuportiu...u& Keyboard interrupt received, exiting.N( R,RRtprintt serve_forevertKeyboardInterruptt server_closeRitexit(t HandlerClasst ServerClasstprotocolRtserver_addressthttpdtsa((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyttests     u__main__u--cgitactionu store_truethelpuRun as CGI Serveruportustoretdefaultttypetnargsu?u&Specify alternate port [default: 8000]R9R(7Rt __future__RRRRtfutureRtfuture.builtinsRt__all__tfuture.backportsRtfuture.backports.httpRR.tfuture.backports.urllibRRR RRRRRRRRiRoRtargparseRRR R R tStreamRequestHandlerRRRRRRRRR?RtArgumentParsertparsert add_argumentR*t parse_argsRhtcgiR(((so/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/site-packages/future/backports/http/server.pyt"s`" 3               +