ó žß¿_c@sþdZdZdgZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z yddl m Z Wn!ek r¸ddl m Z nXdejfd„ƒYZeejd„ZedkrúeƒndS( s’Simple HTTP Server. This module builds on BaseHTTPServer by implementing the standard GET and HEAD requests in a fairly straightforward manner. s0.6tSimpleHTTPRequestHandleriÿÿÿÿN(tStringIOcBs¥eZdZdeZd„Zd„Zd„Zd„Zd„Z d„Z d„Z e j ske jƒne jjƒZejid d 6d d 6d d 6d d6ƒRS(sWSimple 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. s SimpleHTTP/cCs>|jƒ}|r:z|j||jƒWd|jƒXndS(sServe a GET request.N(t send_headtcopyfiletwfiletclose(tselftf((sU/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/SimpleHTTPServer.pytdo_GET+s  cCs#|jƒ}|r|jƒndS(sServe a HEAD request.N(RR(RR((sU/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/SimpleHTTPServer.pytdo_HEAD4s c Csã|j|jƒ}d}tjj|ƒrtj|jƒ}|jjdƒsµ|jdƒ|d|d|dd|d|df}tj |ƒ}|j d|ƒ|j ƒdSxOdD]7}tjj ||ƒ}tjj |ƒr¼|}Pq¼q¼W|j|ƒSn|j|ƒ}yt|d ƒ}Wn"tk rM|jd d ƒdSXyz|jdƒ|j d|ƒtj|jƒƒ}|j dt|dƒƒ|j d|j|jƒƒ|j ƒ|SWn|jƒ‚nXdS(s{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. t/i-iiiiitLocations index.htmls index.htmtrbi”sFile not foundiÈs Content-typesContent-Lengthis Last-ModifiedN(s index.htmls index.htm(ttranslate_pathtpathtNonetostisdirturlparseturlsplittendswitht send_responset urlunsplitt send_headert end_headerstjointexiststlist_directoryt guess_typetopentIOErrort send_errortfstattfilenotstrtdate_time_stringtst_mtimeR( RRRtpartst new_partstnew_urltindextctypetfs((sU/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/SimpleHTTPServer.pyR:sF        c CsÆytj|ƒ}Wn%tjk r:|jddƒdSX|jdd„ƒtƒ}tjt j |j ƒƒ}|j dƒ|j d|ƒ|j d|ƒ|j dƒxž|D]–}tj j ||ƒ}|}}tj j|ƒr|d }|d }ntj j|ƒr"|d }n|j d t j|ƒtj|ƒfƒqµW|j d ƒ|jƒ} |jd ƒ|jdƒtjƒ} |jdd| ƒ|jdt| ƒƒ|jƒ|S(sûHelper 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(). i”sNo permission to list directorytkeycSs |jƒS(N(tlower(ta((sU/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/SimpleHTTPServer.pyt{ts7s/ Directory listing for %s s)

Directory listing for %s

s

iiÈs Content-typestext/html; charset=%ssContent-LengthN(RtlistdirterrorRRtsortRtcgitescapeturllibtunquoteRtwriteRRtislinktquotettelltseekRtsystgetfilesystemencodingRR"R( RRtlistRt displaypathtnametfullnamet displaynametlinknametlengthtencoding((sU/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/SimpleHTTPServer.pyRns>         $      cCsð|jddƒd}|jddƒd}|jƒjdƒ}tjtj|ƒƒ}|jdƒ}td|ƒ}t j ƒ}xS|D]K}t j j |ƒsŠ|t j t jfkrÀqŠnt j j||ƒ}qŠW|rì|d7}n|S(sñTranslate 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.) t?iit#R N(tsplittrstripRt posixpathtnormpathR6R7tfilterRRtgetcwdRtdirnametcurdirtpardirR(RRttrailing_slashtwordstword((sU/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/SimpleHTTPServer.pyR ˜s   * cCstj||ƒdS(sñCopy 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((sU/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/SimpleHTTPServer.pyR²scCsdtj|ƒ\}}||jkr/|j|S|jƒ}||jkrU|j|S|jdSdS(s»Guess 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/N(RKtsplitexttextensions_mapR,(RRtbasetext((sU/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/SimpleHTTPServer.pyRÂs   sapplication/octet-streamR/s text/plains.pys.cs.h(t__name__t __module__t__doc__t __version__tserver_versionRR RRR RRt mimetypestinitedtinitt types_maptcopyRZtupdate(((sU/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/SimpleHTTPServer.pyRs"    4 *      cCstj||ƒdS(N(tBaseHTTPServerttest(t HandlerClasst ServerClass((sU/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/SimpleHTTPServer.pyRiåst__main__(R_R`t__all__RRKRhR6RR4R=RURbt cStringIORt ImportErrortBaseHTTPRequestHandlerRt HTTPServerRiR](((sU/home/tom/ab/renpy-build/tmp/install.android-x86_64/lib/python2.7/SimpleHTTPServer.pyts(           É