a ´i¥Tã@sÄddlmZmZmZddlmZddlZddlZddlZgd¢Z gd¢Z gd¢Z dd „Z hd £j Zd d „Zd d„ZGdd„dƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZdS)é)Ú FileWrapperÚ guess_schemeÚ is_hop_by_hop)ÚHeaderséN)Ú BaseHandlerÚ SimpleHandlerÚBaseCGIHandlerÚ CGIHandlerÚ IISCGIHandlerÚ read_environ)ZMonZTueZWedZThuZFriZSatZSun) NZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDecc Cs:t |¡\ }}}}}}}}} dt||t|||||fS)Nz#%s, %02d %3s %4d %02d:%02d:%02d GMT)ÚtimeÚgmtimeÚ _weekdaynameÚ _monthname) Z timestampZyearZmonthZdayZhhZmmÚssZwdÚyÚz©rú(/usr/lib64/python3.9/wsgiref/handlers.pyÚformat_date_timesÿr> Z CONTENT_TYPEÚ PATH_INFOZ AUTH_TYPEZ REMOTE_IDENTZ REMOTE_USERZREQUEST_METHODZ QUERY_STRINGZHTTPSÚ SCRIPT_NAMEZCONTENT_LENGTHcCs6t|ƒp4| d¡p4| d¡p4| d¡o4t|dd…ƒS)NZHTTP_ZSSL_Z REDIRECT_é )Ú _is_requestÚ startswithÚ_needs_transcode)ÚkrrrrsÿrcCsît ¡}d}zd d|¡Wnty2d}Yn0i}tj ¡D]¦\}}t|ƒràtjdkrÎtj  dd¡  ¡}|  d¡rŠ| d¡  d¡}qà|  d ¡r–qà|  d ¡rºd |vrº| d¡  d¡}qà| |d¡  d¡}n| ||¡  d¡}|||<qB|S) NÚsurrogateescapeÚzutf-8ÚreplaceÚwin32ÚSERVER_SOFTWAREzmicrosoft-iis/ú iso-8859-1zapache/z simplehttp/zpython/3) ÚsysÚgetfilesystemencodingÚencodeÚ LookupErrorÚosÚenvironÚitemsrÚplatformÚgetÚlowerrÚdecode)ÚencZescr)rÚvZsoftwarerrrr "s0     ÿþ r 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 Csrz$| ¡||j|jƒ|_| ¡WnHtttfy>YdSz | ¡Wn|  ¡‚Yn0Yn0dS©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 durx|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)r;Úenvrrrr2˜s          zBaseHandler.setup_environcCsdz2| ¡r| ¡s0|jD]}| |¡q| ¡Wn$t|jdƒrP|j ¡‚Yn 0| ¡dS)Nr:)Úresult_is_fileÚsendfiler4ÚwriteÚfinish_contentÚhasattrr:©r;Údatarrrr5­s     zBaseHandler.finish_responsecCs t|jƒSr1)rr)©r;rrrrDÇszBaseHandler.get_schemec CsHzt|jƒ}Wntttfy&Yn0|dkrDt|jƒ|jd<dSdS)NrúContent-Length)Úlenr4Ú TypeErrorÚAttributeErrorÚNotImplementedErrorÚstrÚ bytes_sentÚheaders)r;ZblocksrrrÚset_content_lengthÌszBaseHandler.set_content_lengthcCsd|jvr| ¡dS)NrT)r[r\rSrrrÚcleanup_headersÙs zBaseHandler.cleanup_headerscCsl|r6z(|jr&|d|dƒ |d¡‚Wd}qHd}0n|jdurHtdƒ‚||_| |¡|_| |d¡}|jS)NrrézHeaders already set!ZStatus)Ú headers_sentÚwith_tracebackr[ÚAssertionErrorÚstatusÚ headers_classÚ_convert_string_typerN)r;rbr[Úexc_inforrrr3ás   zBaseHandler.start_responsecCs(t|ƒtur|Std |t|ƒ¡ƒ‚dS)Nz!{0} must be of type str (got {1}))ÚtyperYraÚformatÚrepr)r;ÚvalueÚtitlerrrrdþs  ÿz BaseHandler._convert_string_typecCs’|jrx| ¡rŽ| d|j|jf d¡¡d|jvrP| dtt ¡ƒ d¡¡|j rŽd|jvrŽ| d|j  d¡¡n| d|j d¡¡dS)Nz HTTP/%s %s r#ZDatez Date: %s ZServerz Server: %s z Status: %s ) rHÚclient_is_modernÚ_writeÚ http_versionrbr&r[rr rIrSrrrÚ send_preambles ÿzBaseHandler.send_preamblecCsR|jstdƒ‚n,|js*t|ƒ|_| ¡n|jt|ƒ7_| |¡| ¡dS)Nzwrite() before start_response())rbrar_rUrZÚ send_headersrlÚ_flushrQrrrrNs    zBaseHandler.writecCsdS)NFrrSrrrrM)szBaseHandler.sendfilecCs"|js|j dd¡| ¡ndS)NrTÚ0)r_r[rJrorSrrrrO>s zBaseHandler.finish_contentc Csjz>t|jdƒr|j ¡Wd|_|_|_|_d|_d|_n&d|_|_|_|_d|_d|_0dS)Nr:rF)rPr4r:r[rbr)rZr_rSrrrr:Hs  ÿzBaseHandler.closecCs8| ¡d|_|jr| ¡r4| ¡| t|jƒ¡dS)NT)r]r_rHrkrnrlÚbytesr[rSrrrroUs zBaseHandler.send_headerscCs|j}|duot|j|ƒSr1)rGÚ isinstancer4)r;ÚwrapperrrrrL^szBaseHandler.result_is_filecCs|jd ¡dkS)NZSERVER_PROTOCOLzHTTP/0.9)r)ÚupperrSrrrrkdszBaseHandler.client_is_moderncCsNzBddlm}| ¡}||d|d|d|j|ƒ| ¡Wd}nd}0dS)Nr)Úprint_exceptionrr^)Ú tracebackrvrAÚtraceback_limitÚflush)r;rervÚstderrrrrÚ log_exceptionis þ zBaseHandler.log_exceptioncCs2| t ¡¡|js.| |j|j¡|_| ¡dSr1) r{r$rer_Ú error_outputr)r3r4r5rSrrrr9yszBaseHandler.handle_errorcCs$||j|jdd…t ¡ƒ|jgSr1)Ú error_statusÚ error_headersr$reÚ error_body)r;r)r3rrrr|s zBaseHandler.error_outputcCst‚dSr1©rXrQrrrrl”szBaseHandler._writecCst‚dSr1r€rSrrrrpszBaseHandler._flushcCst‚dSr1r€rSrrrr@¥szBaseHandler.get_stdincCst‚dSr1r€rSrrrrA©szBaseHandler.get_stderrcCst‚dSr1r€rSrrrr?­szBaseHandler.add_cgi_vars)N)1Ú__name__Ú __module__Ú __qualname__rBrErFrCrHrmrIr r=rrGrrcrxr}r~rrbr4r_r[rZr<r2r5rDr\r]r3rdrnrNrMrOr:rorLrkr{r9r|rlrpr@rAr?rrrrr^sT      rc@s>eZdZddd„Zdd„Zdd„Zd d „Zd d „Zd d„ZdS)rTFcCs(||_||_||_||_||_||_dSr1)ÚstdinÚstdoutrzÚbase_envrErF)r;r„r…rzr)Ú multithreadÚ multiprocessrrrÚ__init__¿s zSimpleHandler.__init__cCs|jSr1)r„rSrrrr@ÉszSimpleHandler.get_stdincCs|jSr1)rzrSrrrrAÌszSimpleHandler.get_stderrcCs|j |j¡dSr1)r)Úupdater†rSrrrr?ÏszSimpleHandler.add_cgi_varscCs^|j |¡}|dus |t|ƒkr$dSddlm}|dtƒ||d…}|sLqZ|j |¡}q:dS)Nr)Úwarnz9SimpleHandler.stdout.write() should not do partial writes)r…rNrUÚwarningsr‹ÚDeprecationWarning)r;rRr4r‹rrrrlÒs  ÿ zSimpleHandler._writecCs|j ¡|jj|_dSr1)r…ryrprSrrrrpßs zSimpleHandler._flushN)TF) rr‚rƒr‰r@rAr?rlrprrrrr²sÿ  rc@seZdZdZdS)r FN)rr‚rƒrHrrrrr äsr c@seZdZdZiZdd„ZdS)r Tc Cs(tj|tjjtjjtjtƒddddS)NFT©r‡rˆ)r r‰r$r„Úbufferr…rzr rSrrrr‰sþzCGIHandler.__init__N©rr‚rƒrCr=r‰rrrrr üsr c@seZdZdZiZdd„ZdS)r Tc Csjtƒ}| dd¡}| dd¡}|d |d¡rD|t|ƒd…|d<tj|tjjtj jtj |ddddS)Nrrrú/FTrŽ) r r,rrUr r‰r$r„rr…rz)r;r)ÚpathZscriptrrrr‰2s  þzIISCGIHandler.__init__Nrrrrrr sr )Úutilrrrr[rr$r(r Ú__all__rrrÚ __contains__rrr rrr r r rrrrÚs   <V2