B ×çq•ã @süddlmZmZmZddlmZddlZddlZddlZddddd d gZ d d d ddddgZ dddddddddddddg Z dd„Z d d!d"d#d$d%d&d'd(d)h j Zd*d+„Zd,d „ZGd-d„dƒZGd.d„deƒZGd/d„deƒZGd0d„deƒZGd1d „d eƒZdS)2é)Ú FileWrapperÚ guess_schemeÚ is_hop_by_hop)ÚHeaderséNÚ BaseHandlerÚ SimpleHandlerÚBaseCGIHandlerÚ CGIHandlerÚ IISCGIHandlerÚ read_environZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecc Cs:t |¡\ }}}}}}}}} dt||t|||||fS)Nz#%s, %02d %3s %4d %02d:%02d:%02d GMT)ÚtimeZgmtimeÚ _weekdaynameÚ _monthname) Z timestampZyearZmonthZdayZhhZmmÚssZwdÚyÚz©rú3/opt/alt/python37/lib/python3.7/wsgiref/handlers.pyÚformat_date_timesrÚ SCRIPT_NAMEÚ PATH_INFOZ QUERY_STRINGZREQUEST_METHODZ AUTH_TYPEZ CONTENT_TYPEZCONTENT_LENGTHZHTTPSZ REMOTE_USERZ REMOTE_IDENTcCs6t|ƒp4| d¡p4| d¡p4| d¡o4t|dd…ƒS)NZHTTP_ZSSL_Z REDIRECT_é )Ú _is_requestÚ startswithÚ_needs_transcode)ÚkrrrrsrcCsôt ¡}d}yd d|¡Wntk r4d}YnXi}x´tj ¡D]¦\}}t|ƒrätjdkrÒtj  dd¡  ¡}|  d¡rŽ| d¡  d¡}qä|  d ¡ršqä|  d ¡r¾d |kr¾| d¡  d¡}qä| |d¡  d¡}n| ||¡  d¡}|||<qFW|S) NÚsurrogateescapeÚzutf-8ÚreplaceÚwin32ÚSERVER_SOFTWAREzmicrosoft-iis/z iso-8859-1zapache/z simplehttp/zpython/3) ÚsysÚgetfilesystemencodingÚencodeÚ LookupErrorÚosÚenvironÚitemsrÚplatformÚgetÚlowerrÚdecode)ÚencZescr'rÚvZsoftwarerrrr "s,      c@seZdZdZdZdZdZdZdZdZ e ƒZ e Z eZdZdZdgZdZdZZdZdZd Zd d „Zd d „Zdd„Zdd„Zdd„Zdd„Zd:dd„Zdd„Z dd„Z!dd„Z"dd„Z#d d!„Z$d"d#„Z%d$d%„Z&d&d'„Z'd(d)„Z(d*d+„Z)d,d-„Z*d.d/„Z+d0d1„Z,d2d3„Z-d4d5„Z.d6d7„Z/d8d9„Z0dS);r)rrTFz1.0Nz500 Internal Server Error)z Content-Typez text/plains;A server error occurred. Please contact the administrator.rc Csry$| ¡||j|jƒ|_| ¡WnHtttfk r>dSy | ¡Wn|  ¡‚YnXYnXdS)N) Ú setup_environr'Ústart_responseÚresultÚfinish_responseÚConnectionAbortedErrorÚBrokenPipeErrorÚConnectionResetErrorÚ handle_errorÚclose)ÚselfZ applicationrrrÚrun€s  zBaseHandler.runcCs–|j ¡}|_| ¡| ¡|d<| ¡|d<|j|d<|j|d<| ¡|d<|j |d<|j |d<|j dk rx|j |d<|j r’|j r’| d |j ¡dS) Nz wsgi.inputz wsgi.errorsz wsgi.versionz wsgi.run_oncezwsgi.url_schemezwsgi.multithreadzwsgi.multiprocesszwsgi.file_wrapperr!)Ú os_environÚcopyr'Ú add_cgi_varsÚ get_stdinÚ get_stderrÚ wsgi_versionÚ wsgi_run_onceÚ get_schemeÚwsgi_multithreadÚwsgi_multiprocessÚwsgi_file_wrapperÚ origin_serverÚserver_softwareÚ setdefault)r8Úenvrrrr/˜s          zBaseHandler.setup_environcCshy6| ¡r| ¡s4x|jD]}| |¡qW| ¡Wn$t|jdƒrT|j ¡‚Yn X| ¡dS)Nr7)Úresult_is_fileÚsendfiler1ÚwriteÚfinish_contentÚhasattrr7)r8Údatarrrr2­s    zBaseHandler.finish_responsecCs t|jƒS)N)rr')r8rrrrAÇszBaseHandler.get_schemec CsJyt|jƒ}Wntttfk r(YnX|dkrFt|jƒ|jd<dSdS)NrzContent-Length)Úlenr1Ú TypeErrorÚAttributeErrorÚNotImplementedErrorÚstrÚ bytes_sentÚheaders)r8ZblocksrrrÚset_content_lengthÌszBaseHandler.set_content_lengthcCsd|jkr| ¡dS)NzContent-Length)rUrV)r8rrrÚcleanup_headersÙs zBaseHandler.cleanup_headerscCsh|r2z$|jr&|d|dƒ |d¡‚Wdd}Xn|jdk rDtdƒ‚||_| |¡|_| |d¡}|jS)NrrézHeaders already set!ZStatus)Ú headers_sentÚwith_tracebackrUÚAssertionErrorÚstatusÚ headers_classÚ_convert_string_typerK)r8r\rUÚexc_inforrrr0ás   zBaseHandler.start_responsecCs(t|ƒtkr|Std |t|ƒ¡ƒ‚dS)Nz!{0} must be of type str (got {1}))ÚtyperSr[ÚformatÚrepr)r8ÚvalueÚtitlerrrr^ýs z BaseHandler._convert_string_typecCs’|jrx| ¡rŽ| d|j|jf d¡¡d|jkrP| dtt ¡ƒ d¡¡|j rŽd|jkrŽ| d|j  d¡¡n| d|j d¡¡dS)Nz HTTP/%s %s z iso-8859-1ZDatez Date: %s ZServerz Server: %s z Status: %s ) rEÚclient_is_modernÚ_writeÚ http_versionr\r$rUrr rF)r8rrrÚ send_preambles zBaseHandler.send_preamblecCsR|jstdƒ‚n,|js*t|ƒ|_| ¡n|jt|ƒ7_| |¡| ¡dS)Nzwrite() before start_response())r\r[rYrOrTÚ send_headersrfÚ_flush)r8rNrrrrKs    zBaseHandler.writecCsdS)NFr)r8rrrrJ(szBaseHandler.sendfilecCs"|js|j dd¡| ¡ndS)NzContent-LengthÚ0)rYrUrGri)r8rrrrL=s zBaseHandler.finish_contentc CsFzt|jdƒr|j ¡Wdd|_|_|_|_d|_d|_XdS)Nr7rF)rMr1r7rUr\r'rTrY)r8rrrr7Gs  zBaseHandler.closecCs8| ¡d|_|jr| ¡r4| ¡| t|jƒ¡dS)NT)rWrYrErerhrfÚbytesrU)r8rrrriTs zBaseHandler.send_headerscCs|j}|dk ot|j|ƒS)N)rDÚ isinstancer1)r8ÚwrapperrrrrI]szBaseHandler.result_is_filecCs|jd ¡dkS)NZSERVER_PROTOCOLzHTTP/0.9)r'Úupper)r8rrrrecszBaseHandler.client_is_moderncCsJz>ddlm}| ¡}||d|d|d|j|ƒ| ¡Wdd}XdS)Nr)Úprint_exceptionrrX)Ú tracebackrpr>Útraceback_limitÚflush)r8r_rpÚstderrrrrÚ log_exceptionhs   zBaseHandler.log_exceptioncCs2| t ¡¡|js.| |j|j¡|_| ¡dS)N) rur"r_rYÚ error_outputr'r0r1r2)r8rrrr6xszBaseHandler.handle_errorcCs$||j|jdd…t ¡ƒ|jgS)N)Ú error_statusÚ error_headersr"r_Ú error_body)r8r'r0rrrrv€s zBaseHandler.error_outputcCst‚dS)N)rR)r8rNrrrrf“szBaseHandler._writecCst‚dS)N)rR)r8rrrrjœszBaseHandler._flushcCst‚dS)N)rR)r8rrrr=¤szBaseHandler.get_stdincCst‚dS)N)rR)r8rrrr>¨szBaseHandler.get_stderrcCst‚dS)N)rR)r8rrrr<¬szBaseHandler.add_cgi_vars)N)1Ú__name__Ú __module__Ú __qualname__r?rBrCr@rErgrFr r:rrDrr]rrrwrxryr\r1rYrUrTr9r/r2rArVrWr0r^rhrKrJrLr7rirIrerur6rvrfrjr=r>r<rrrrr^sT      c@s>eZdZddd„Zdd„Zdd„Zd d „Zd d „Zd d„ZdS)rTFcCs(||_||_||_||_||_||_dS)N)ÚstdinÚstdoutrtÚbase_envrBrC)r8r}r~rtr'Ú multithreadÚ multiprocessrrrÚ__init__¾s zSimpleHandler.__init__cCs|jS)N)r})r8rrrr=ÈszSimpleHandler.get_stdincCs|jS)N)rt)r8rrrr>ËszSimpleHandler.get_stderrcCs|j |j¡dS)N)r'Úupdater)r8rrrr<ÎszSimpleHandler.add_cgi_varscCsb|j |¡}|dks |t|ƒkr$dSddlm}|dtƒx"||d…}|sNP|j |¡}qr<rfrjrrrrr±s   c@seZdZdZdS)r FN)rzr{r|rErrrrr ãsc@seZdZdZiZdd„ZdS)r Tc Cs(tj|tjjtjjtjtƒddddS)NFT)r€r)r r‚r"r}Úbufferr~rtr )r8rrrr‚szCGIHandler.__init__N)rzr{r|r@r:r‚rrrrr ûsc@seZdZdZiZdd„ZdS)r Tc Csjtƒ}| dd¡}| dd¡}|d |d¡rD|t|ƒd…|d<tj|tjjtj jtj |ddddS)Nrrrú/FT)r€r) r r*rrOr r‚r"r}r‡r~rt)r8r'ÚpathZscriptrrrr‚1s  zIISCGIHandler.__init__N)rzr{r|r@r:r‚rrrrr s)ÚutilrrrrUrr"r&r Ú__all__rrrÚ __contains__rrr rrr r r rrrrÚs(   <U2