bgӱdZddlmZmZmZmZddlmZddlTdZ ddgZ ddl m Z dd l mZdd lmZdd l mZdd lZdd lZdd lZdd lZdd lZdd lZdd lZdd lZdd lZdd lZdd lZd ZdZ dZ!Gddej"Z#Gddej$Z%Gdde%Z&dZ'd a(dZ)dZ*Gdde&Z+e%e#ddfdZ,e-dkrej.Z/e/0ddd e/0d!d"de1d#d$%e/2Z3e3j4re,e+e3j5&d Se,e&e3j5&d Sd S)'aQHTTP 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 )absolute_importdivisionprint_functionunicode_literals)utils)*z0.6 HTTPServerBaseHTTPRequestHandlerhtml)client)parse) socketserverNa Error response

Error response

Error code: %(code)d

Message: %(message)s.

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

ztext/html;charset=utf-8ct|jddddddS)N&z&z>)replacer s m/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/future/backports/http/server.py _quote_htmlrs6 4<W % % - -c6 : : B B3 O OOceZdZdZdZdS)r ctj||jdd\}}tj||_||_dS)z.Override server_bind to store the server name.N)r TCPServer server_bindsocket getsocknamegetfqdn server_name server_port)selfhostports rrzHTTPServer.server_bindsY**4000[,,..rr2 d!>$//rN)__name__ __module__ __qualname__allow_reuse_addressrrrr r s)     rc eZdZdZdejdzZdezZ e Z e Z dZdZdZdZd Zdkd Zdkd Zdkd ZdZdZdZdldZdZdZdZdkdZdZgdZgdZ dZ!dZ"e#j$Z%iddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;dd?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidj Z&d S)mr aHTTP 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". zPython/rz BaseHTTP/HTTP/0.9c,d|_|jx|_}d|_t |jd}|d}||_|}t|dkr|\}}}|dddkr| dd |zd S |d dd}|d }t|d krtt|dt|df}n1#ttf$r| dd |zYd SwxYw|dkr|jdkrd|_|dkr| dd|zd Sn`t|d kr.|\}}d|_|dkr| dd|zd Sn|sd S| dd|zd S|||c|_|_|_ t!j|j|j|_n,#t j$r| ddYd SwxYw|jdd}|dkrd|_n*|dkr|jdkrd|_|jdd} | dkr,|jdkr!|jdkr|sd SdS) 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. Nrz iso-8859-1 zHTTP/zBad request version (%r)F/.rr)rrzHTTP/1.1)rrzInvalid HTTP Version (%s)GETzBad HTTP/0.9 request type (%r)zBad request syntax (%r))_classz Line too long Connectionclose keep-aliveExpectz 100-continueT)commanddefault_request_versionrequest_versionclose_connectionstrraw_requestlinerstrip requestlinesplitlen send_error ValueErrorint IndexErrorprotocol_versionpath http_client parse_headersrfile MessageClassheaders LineTooLonggetlowerhandle_expect_100) r#versionrCwordsr<rKbase_version_numberversion_numberconntypeexpects r parse_requestz$BaseHTTPRequestHandler.parse_request s )-)EEw !$. == !((00 &!!## u::??%* "GT7rr{g%%%?'%IJJJu &-mmC&;&;A&>#!4!:!:3!?!?~&&!++$$!$^A%6!7!7^A=N9O9O!O +   %?'%IJJJuu ''D,AZ,O,O()%''58KKMMMu(ZZ1__!MGT$%D !% @7 JLLLu  5 OOC!:[!H I I I58?w5 di!5 &4TZ<@>  w & &$%D ! !nn,..#z11$%D !!!(B// LLNNn , ,%33$ 22))++ uts%&A5D*E  E >%H$$%I  I cX|d|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. dT)send_response_only flush_headersr#s rrTz(BaseHTTPRequestHandler.handle_expect_100]s/ $$$ trch |jd|_t|jdkr,d|_d|_d|_|ddS|js d|_dS| sdSd|jz}t||s |dd |jzdSt||}||j dS#tj$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. iir8Nrdo_zUnsupported method (%r)zRequest timed out: %r)rNreadlinerArErCr>r<rFr?r[hasattrgetattrwfileflushrtimeout log_error)r#mnamemethodes rhandle_one_requestz)BaseHTTPRequestHandler.handle_one_requestosR #':#6#6u#=#=D 4'((500#% ')$! $$$' ()%%%'' DL(E4'' %>%MNNNT5))F FHHH J       ~    NN2A 6 6 6$%D ! FFFFF  s0A!C:%C:5C: 8C:3C::D1 D,,D1cd|_||js||jdSdS)z&Handle multiple requests if necessary.rN)r?ror`s rhandlezBaseHTTPRequestHandler.handlesZ ! !!!' &  # # % % %' & & & & &rNc  |j|\}}n#t$rd\}}YnwxYw||}|}|d|||j|t ||dz}||||d|j|dd||j dkr:|d kr6|d vr4|j | d d dSdSdSdS) aSend 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. )???rsNzcode %d, message %s)codemessageexplainz Content-Typer7r9HEAD)0zUTF-8r) responsesKeyErrorrkerror_message_formatr send_response send_headererror_content_type end_headersr<rhwriteencode)r#rtrushortmsglongmsgrvcontents rrFz!BaseHTTPRequestHandler.send_errors> - $t 4 Hgg - - - , Hggg - ?G ,dG<<<, [-A-AgVVW 4))) )@AAA w///  <6 ! !dckkd*6L6L J  W^^GY?? @ @ @ @ @ " !kk6L6Ls %%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_requestr^rversion_stringdate_time_stringr#rtrus rr~z$BaseHTTPRequestHandler.send_responsesx  g... 4#6#6#8#8999 !6!6!8!899999rc|||jvr|j|d}nd}|jdkrRt|dsg|_|jd|j||fzdddSdS) zSend the response header only.Nrr8r,_headers_bufferz %s %d %s latin-1strict)r{r>rfrappendrJrrs rr^z)BaseHTTPRequestHandler.send_response_onlys ?t~%%..q1  : - -4!233 *')$  ' '*D':*;rfrrrrSr?)r#keywordvalues 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>rrr_r`s rrz"BaseHTTPRequestHandler.end_headerssG  : - -  ' ' 0 0 0     . -rct|dr;|jd|jg|_dSdS)Nrr)rfrhrjoinrr`s rr_z$BaseHTTPRequestHandler.flush_headerssR 4* + + & J  SXXd&:;; < < <#%D  & &r-ct|d|jt|t|dS)zNLog an accepted request. This is called by send_response(). z "%s" %s %sN) log_messagerCr@)r#rtsizes rrz"BaseHTTPRequestHandler.log_requestsC )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)rr#formatargss rrkz BaseHTTPRequestHandler.log_errors% '$''''''rctj|d|d||zddS)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 - - [z]  N)sysstderrraddress_stringlog_date_time_stringrs rrz"BaseHTTPRequestHandler.log_messagesb" --////335555 +++' ( ( ( ( (rc&|jdz|jzS)z*Return the server software version string. )server_version sys_versionr`s rrz%BaseHTTPRequestHandler.version_strings"S(4+;;;rc |tj}tj|\ }}}}}}}} } d|j|||j|||||fz} | S)z@Return the current date and time formatted for a message header.Nz#%s, %02d %3s %4d %02d:%02d:%02d GMT)timegmtime weekdayname monthname) r# timestampyearmonthdayhhmmsswdyzss rrz'BaseHTTPRequestHandler.date_time_stringsk   I15Y1G1G.eS"b"b!Q 1 $T^E*DB5 rc tj}tj|\ }}}}}}}} } d||j|||||fz} | S)z.Return the current time formatted for logging.z%02d/%3s/%04d %02d:%02d:%02d)r localtimer) r#nowrrrrrrxrrrs rrz+BaseHTTPRequestHandler.log_date_time_string*sWikk04s0C0C-eS"b"aA *T^E*D"b".> >r)MonTueWedThuFriSatSun) NJanFebMarAprMayJunJulAugSepOctNovDecc|jdS)zReturn the client address.r)client_addressr`s rrz%BaseHTTPRequestHandler.address_string8s"1%%rHTTP/1.0r])Continuez!Request received, please continuee)zSwitching Protocolsz.Switching to new protocol; obey Upgrade headerrx)OKz#Request fulfilled, document follows)CreatedzDocument created, URL follows)Acceptedz/Request accepted, processing continues off-line)zNon-Authoritative InformationzRequest fulfilled from cachery)z No Contentz"Request fulfilled, nothing follows)z Reset Contentz#Clear input form for further input.)zPartial ContentzPartial content follows.i,)zMultiple Choicesz,Object has several resources -- see URI list-)zMoved Permanentlyz(Object moved permanently -- see URI listi.)Found(Object moved temporarily -- see URI listi/)z See Otherz'Object moved -- see Method and URL listrz)z Not Modifiedz)Document has not changed since given timei1)z Use ProxyzAYou must use proxy specified in Location to access this resource.i3)zTemporary Redirectrr1)z Bad Requestz(Bad request syntax or unsupported methodi) Unauthorizedz*No permission -- see authorization schemesi)zPayment Requiredz"No payment -- see charging schemes) Forbiddenz0Request forbidden -- authorization will not help)z Not FoundzNothing matches the given URIi)zMethod Not Allowedz.Specified method is invalid for this resource.i)zNot Acceptablez&URI not available in preferred format.i)zProxy Authentication Requiredz8You must authenticate with this proxy before proceeding.i)zRequest Timeoutz#Request timed out; try again later.i)ConflictzRequest conflict.i)Gonez6URI no longer exists and has been permanently removed.i)zLength Requiredz#Client must specify Content-Length.i)zPrecondition Failedz!Precondition in headers is false.i)zRequest Entity Too LargezEntity is too large.rb)zRequest-URI Too LongzURI is too long.i)zUnsupported Media Typez"Entity body in unsupported format.i)zRequested Range Not SatisfiablezCannot satisfy request range.i)zExpectation Failedz(Expect condition could not be satisfied.)zPrecondition Requiredz9The origin server requires the request to be conditional.)zToo Many RequestszPThe user has sent too many requests in a given amount of time ("rate limiting").)zRequest Header Fields Too LargezWThe server is unwilling to process the request because its header fields are too large.)zInternal Server ErrorzServer got itself in trouble)zNot Implementedz&Server does not support this operation)z Bad Gatewayz,Invalid responses from another server/proxy.)zService Unavailablez8The server cannot process the request due to a high load)zGateway Timeoutz4The gateway server did not receive a timely response)zHTTP Version Not SupportedzCannot fulfill request.)zNetwork Authentication Requiredz8The client needs to authenticate to gain network access.) iiiirdiiir4iN)rr)'r&r'r(__doc__rrUrDr __version__rDEFAULT_ERROR_MESSAGEr}DEFAULT_ERROR_CONTENT_TYPErr=r[rTrorqrFr~r^rrr_rrkrrrrrrrrJrL HTTPMessagerOr{r*rrr r s%ddNck//11!44K !;.N03 )OOOb$!!!F&&&AAAA> : : : : . . . . * * *!!! &&& AAAA ( ( ((((,<<<    DCCK;;;I&&&"*L H  >H  @H : H 9 H  AH  NH  AH  EH  <H  >H N!H " B#H $ E%H & ;'H * +H 0 :1H 6 :7H H : <;H > 4?H B BCH F ;GH H @IH L IMH N /OH R GSH T .UH V HWH Z G[H \ I]H ^ A_H ` 9aH b McH d /eH h :iH H lK>NG8 LJF FJMH H H IIIrceZdZdZdezZdZdZdZdZ dZ dZ d Z e jse je jZed d d d d d S)SimpleHTTPRequestHandleraWSimple 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. z SimpleHTTP/c|}|r1|||j|dSdS)zServe a GET request.N) send_headcopyfilerhr9r#fs rdo_GETzSimpleHTTPRequestHandler.do_GETsJ NN     MM!TZ ( ( ( GGIIIII  rc^|}|r|dSdS)zServe a HEAD request.N)rr9rs rdo_HEADz SimpleHTTPRequestHandler.do_HEADs4 NN     GGIIIII  rc||j}d}tj|r|jdsI|d|d|jdz|dSdD]E}tj||}tj |r|}nF| |S| |} t|d}n'#t$r|ddYdSwxYw|d |d |tj|}|d t#|d |d ||j||S)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. Nr2rLocation)z index.htmlz index.htmrbrzFile not foundrx Content-typeContent-Lengthz Last-Modified)translate_pathrKosisdirendswithr~rrrexistslist_directory guess_typeopenIOErrorrFfstatfilenor@rst_mtime)r#rKrindexctypefss rrz"SimpleHTTPRequestHandler.send_heads""49--  7==   19%%c** ""3'''  TY_===  """t2 1 1 T5117>>%(( DE**4000%% T4  AA    OOC!1 2 2 244  3 /// Xahhjj ! ! )3r!u::666 $*?*? *L*LMMM sD## EEc  tj|}n,#tj$r|ddYdSwxYw|dg}t jtj|j }tj }d|z}| d| d| d |z| d |z| d |z| d |D]}tj ||}|x} } tj |r |d z} |d z} tj |r|dz} | dtj| dt j| d| dd ||} t%j} | | | d|d|dd|z|dt1t3| || 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(). rzNo permission to list directoryNc*|Sr)rS)as rz9SimpleHTTPRequestHandler.list_directory..s r)keyzDirectory listing for %szZz z@z%s z

%s

z
    r2@z
  • z
  • z

rrrxrztext/html; charset=%sr)rlistdirerrorrFsortr escape urllib_parseunquoterKrgetfilesystemencodingrrrislinkquoterioBytesIOrseekr~rr@rEr) r#rKlistr displaypathenctitlenamefullname displaynamelinknameencodedrs rrz'SimpleHTTPRequestHandler.list_directorys :d##DDx    OOC!B C C C44  )) *** k,"6ty"A"ABB '))*[8 < = = = !""" 469: ; ; ; -5666 &.///  P PDw||D$//H%) )K(w}}X&& &"Sj #:w~~h'' )"Sj HHH#)(3333T[5M5M5M5MO P P P P 2333))A,,%%c** JLL  q  3 )@3)FGGG )3s7||+<+<=== s%AAc:|ddd}|ddd}tjtj|}|d}t d|}t j}|D]}t j |\}}t j|\}}|t j t j fvrat j ||}|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#r2N) rD posixpathnormpathrrfilterrgetcwdrK splitdrivecurdirpardirr)r#rKrVworddriveheads rrz'SimpleHTTPRequestHandler.translate_path szz#a  #zz#a  #!,"6t"<"<== 3tU##y{{ , ,D',,T22KE4t,,JD$ 29---x7<<d++DD rc0tj||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)shutil copyfileobj)r#source outputfiles rrz!SimpleHTTPRequestHandler.copyfile#s 6:.....rctj|\}}||jvr |j|S|}||jvr |j|S|jdS)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. r8)r-splitextextensions_maprS)r#rKbaseexts rrz#SimpleHTTPRequestHandler.guess_type3sk&t,, c $% % %&s+ +iikk $% % %&s+ +&r* *rzapplication/octet-streamz text/plain)r8.pyz.cz.hN)r&r'r(rrrrrrrrrr mimetypesinitedinit types_mapcopyr>updater*rrrrs  #[0N '''R222h,/// +++0   (--//N &        rrc|d}g}|ddD]:}|dkr||r|dkr||;|r<|}|r%|dkr|d}n |dkrd}nd}dd|z|f}d|}|S)a` 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. r2Nz..r3r8)rDpoprr)rK path_parts head_partspart tail_part splitpathcollapsed_paths r_url_collapse_pathrQXs$CJJ3B3&& 4<< NN      &dckk   t % % % NN$$  D      c!!  sxx +++Y7IXXi((N rctrtS ddl}n#t$rYdSwxYw |ddan>#t$r1dt d|DzaYnwxYwtS)z$Internal routine to get nobody's uidrNrInobodyrrc3&K|] }|dV dS)rNr*).0rs r znobody_uid..s&66!1666666r)rSpwd ImportErrorgetpwnamr|maxgetpwall)rWs r nobody_uidr\s  rr7h''* 777S66s||~~6666667 Ms ##A8A>=A>c@tj|tjS)zTest for executable file.)raccessX_OK)rKs r executabler`s 9T27 # ##rcZeZdZdZeedZdZdZdZ dZ ddgZ d Z d Z d Zd S) CGIHTTPRequestHandlerzComplete 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|dddS)zRServe a POST request. This is only implemented for CGI scripts. rdzCan only POST to CGI scriptsN)is_cgirun_cgirFr`s rdo_POSTzCGIHTTPRequestHandler.do_POSTsA ;;== A LLNNNNN OOC!? @ @ @ @ @rc|r|St|S)z-Version of send_head that support CGI scripts)rerfrrr`s rrzCGIHTTPRequestHandler.send_heads4 ;;== <<<>> !+55d;; ;rct|j}|dd}|d|||dzd}}||jvr ||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). r2rNTF)rQrKfindcgi_directoriescgi_info)r#rPdir_sepr6tails rrezCGIHTTPRequestHandler.is_cgisj,DI66 %%c1--#HWH-~gaijj/Id 4' ' ' $JDM4urz/cgi-binz/htbinc t|S)z1Test whether argument path is an executable file.)r`)r#rKs r is_executablez#CGIHTTPRequestHandler.is_executables$rcrtj|\}}|dvS)z.Test whether argument path is a Python script.)rAz.pyw)rrKr=rS)r#rKr6rns r is_pythonzCGIHTTPRequestHandler.is_pythons.W%%d++ dzz||..rc|j}|j\}}|dt|dz}|dkr}|d|}||dzd}||}t j|r+||}}|dt|dz}nn|dk}|d}|dkr|d|||dzd}}nd}|d}|dkr|d|||d}} n|d}} |dz| z} || } t j| s| dd| zdSt j | s| d d | zdS| | } |j s| s0| | s| d d | zdStjt j} || d <|jj| d <d| d<|j| d<t+|jj| d<|j| d<t1j|}|| d<||| d<| | d<|r|| d<|jd| d<|jd}|r|}t|dkrddl}ddl}|d| d<|d dkr |d!d}tDj#r)|$|%d}n(|&|%d}|d}t|dkr |d| d<n#|j'tPf$rYnwxYw|jd|j)| d <n|jd| d <|jd!}|r|| d"<|jd#}|r|| d$<g}|j*d%D]V}|ddd&vr(|+|,6||d'dd(z}Wd(-|| d)<|jd*}|r|| d+<t]d|j/d,g}d--|}|r|| d.<d/D]}| 0|d|1d0d1|2|3d2d3}|j r| g}d4|vr|+|ti}|j56t j7}|dkrt j8|d\}}tsj9|j:gggddr>|j:;dsn#tsj9|j:gggdd>|r|<d5|dS t j=|n#t j>$rYnwxYwt j?|j:@dt j?|j5@dt jA| || dS#|jB|jC|jt jDd6YdSxYwddlE}| g} | | rOtjG}!|! Hd7r|!dd8|!d9dz}!|!d:g| z} d4|vr| +||Id;|J|  t|}"n#ttf$rd}"YnwxYw|N| |jO|jO|jO| <}#|j d=kr!|"dkr|j:;|"}$nd}$tsj9|j:jPgggddrH|j:jPQdsn(tsj9|j:jPgggddH|#R|$\}%}&|j5S|%|&r|<d>|&|#jTU|#jVU|#jW}'|'r|<d5|'dS|Id?dS)@zExecute a CGI script.r2rrNr+r8rzNo such CGI script (%r)rz#CGI script is not a plain file (%r)z!CGI script is not executable (%r)SERVER_SOFTWARE SERVER_NAMEzCGI/1.1GATEWAY_INTERFACESERVER_PROTOCOL SERVER_PORTREQUEST_METHOD PATH_INFOPATH_TRANSLATED SCRIPT_NAME QUERY_STRING REMOTE_ADDR authorizationr AUTH_TYPEbasicascii: REMOTE_USERz content-type CONTENT_TYPEzcontent-lengthCONTENT_LENGTHreferer HTTP_REFERERacceptz , HTTP_ACCEPTz user-agentHTTP_USER_AGENTcookiez, HTTP_COOKIE)r} REMOTE_HOSTrrrrrxzScript output follows+r=zCGI script exit status %#xzw.exez-uz command: %s)stdinstdoutrenvpostz%szCGI script exited OK)XrKrlrjrErrrrfindrrFisfilerr have_forkrprFdeepcopyenvironrserverr!rJr@r"r<rrrrPrRrDbase64binasciirSrrPY3 decodebytesdecode decodestringError UnicodeErrorget_content_typegetallmatchingheadersrstriprr/get_all setdefaultr~r_rr\rhrircwaitpidselectrNreadrksetuidrdup2r execve handle_errorrequest_exit subprocessrr`rr list2cmdlinerH TypeErrorrGPopenPIPE_sockrecv communicaterrr9r returncode)(r#rKdirrestinextdirnextrest scriptdirqueryscript scriptname scriptfileispyruqrestrrrlengthrrlineuaco cookie_strk decoded_queryrrSpidstsrcmdlineinterpnbytespdatarrstatuss( rrfzCGIHTTPRequestHandler.run_cgis yM T IIc3s88a< ( (1ff2A2hGAaCDDzH++G44Iw}}Y'' #XTIIc3s88a<001ff JJsOO 66rr(D1J%DDE IIcNN 668T!""XDFFDF3Y' ((44 w~~j))  OOC!:Z!G H H H Fw~~j))  OOC!F&"' ( ( ( F~~j)) >  %%j11 %H *&+,,,mBJ''!%!4!4!6!6 ![4M#,  !%!6  !899M $  %d++!K!%!4!4V!,>},M,M,2F7OO*M-3,?,? ,N,N,2F7OO* )6(;(;C(@(@ }--221>q1AC . %NL9 <  N + + 3"&,"?"?"A"AC  "&,~">C !!"233  +$*C !,""9--  *")C L66x@@ 6 6DBQBx9$$ djjll++++$qrr(.."5"55 XXf--M \  l + +  (%'C! " D$,..x<< = =YYr]]  ,!+C D " "A NN1b ! ! ! ! 3 7888  c3// >H 98D-'' M***\\F J     '))Caxx:c1--SmTZL"b!<>**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?A8O++O?>O?[%$]*%[74]*6[77A1]**;^(a))a?>a?N)r&r'r(rrfrrrbufsizergrrerkrprrrfr*rrrbrbsF##IH A A A<<<0"8,O   /// D9D9D9D9D9rrbri@c^d|f}||_|||}|j}td|dd|dd |dS#t $r;td|tjdYdSwxYw) zTest the HTTP request handler class. This runs an HTTP server on port 8000 (or the first command line argument). r8zServing HTTP onrr%rz...z& Keyboard interrupt received, exiting.N) rJrrprint serve_foreverKeyboardInterrupt server_closerexit) HandlerClass ServerClassprotocolr%server_addresshttpdsas rtestrs$ZN$,L! K 5 5E  ! ! # #B RUFBqE5999   7888   sA''AB,+B,__main__z--cgi store_truezRun as CGI Server)actionhelpr%storer+z&Specify alternate port [default: 8000])rdefaulttypenargsr)rr%)6r __future__rrrrfuturerfuture.builtinsr__all__future.backportsr future.backports.httpr rLfuture.backports.urllibrrrrrBrr-rr8rrrrFargparserrrrr StreamRequestHandlerr rrQrSr\r`rbrr&ArgumentParserparser add_argumentrH parse_argsrcgir%r*rrrsB!!F::::::::::::f 1 2!!!!!!777777999999))))))   "7PPP      '    ~ ~ ~ ~ ~ \>~ ~ ~ B     5   H'''V     $$$ K9K9K9K9K94K9K9K9\/!JT, z $X $ & &F  /111 w $3!EGGG     D xD /di@@@@@@ 2CCCCCCr