Ë ,ÈHÆèË4ãóò—dZddlmZmZmZddlmZddlZddlZddl Z gd¢Z gd¢Z gd¢Z d „Z hd £jZd „Zd „ZGd „d«ZGd„de«ZGd„de«ZGd„de«ZGd„de«Zy)z/Base classes for server/gateway implementationsé)Ú FileWrapperÚ guess_schemeÚ is_hop_by_hop)ÚHeaderséN)Ú BaseHandlerÚ SimpleHandlerÚBaseCGIHandlerÚ CGIHandlerÚ IISCGIHandlerÚ read_environ)ÚMonÚTueÚWedÚThuÚFriÚSatÚSun) NÚJanÚFebÚMarÚAprÚMayÚJunÚJulÚAugÚSepÚOctÚNovÚDecc ót—tj|«\ }}}}}}}}} dt||t|||||fzS)Nz#%s, %02d %3s %4d %02d:%02d:%02d GMT)ÚtimeÚgmtimeÚ _weekdaynameÚ _monthname) Ú timestampÚyearÚmonthÚdayÚhhÚmmÚssÚwdÚyÚzs ú'/usr/lib/python3.12/wsgiref/handlers.pyÚformat_date_timer1sN€Ü-1¯[©[¸Ó-CÑ*€Dˆ%��b˜"˜b " a¨Ø 0Ü�Rј#œz¨%Ñ0°$¸¸BÀð4ñ ðó> ÚHTTPSÚ AUTH_TYPEÚ PATH_INFOÚ REMOTE_USERÚ SCRIPT_NAMEÚ CONTENT_TYPEÚ QUERY_STRINGÚ REMOTE_IDENTÚCONTENT_LENGTHÚREQUEST_METHODcóª—t|«xsG|jd«xs4|jd«xs!|jd«xrt|dd«S)NÚHTTP_ÚSSL_Ú REDIRECT_é )Ú _is_requestÚ startswithÚ_needs_transcode)Úks r0rDrDsT€Ü �q‹>ò C˜QŸ\™\¨'Ó2ò C°a·l±lÀ6Ó6Jò CØ �L‰L˜Ó %Ò AÔ*:¸1¸Q¸R¸5Ó*AðCr2cóì—tj«}d} djd|«i}tj j «D�]\}}t|«rþtjdk(rÊtj jdd«j«}|jd«r!|jd«jd«}n‹|jd «rny|jd «r%d |vr!|jd«jd«}nC|j|d«jd«}n!|j||«jd«}|||<�Œ|S#t$rd}Y�ŒHwxYw) z'Read environment, fixing HTTP variablesÚsurrogateescapeÚzutf-8ÚreplaceÚwin32ÚSERVER_SOFTWAREzmicrosoft-iis/ú iso-8859-1zapache/z simplehttp/zpython/3) ÚsysÚgetfilesystemencodingÚencodeÚ LookupErrorÚosÚenvironÚitemsrDÚplatformÚgetÚlowerrCÚdecode)ÚencÚescrRrEÚvÚsoftwares r0r r "sQ€ä × #Ñ #Ó %€CØ €CðØ � ‰ �'˜3Ôð€Gô — ‘ × Ñ ×"‰ˆˆ1Ü ˜AÔ ô�|‰|˜wÒ&ÜŸ:™:Ÿ>™>Ð*;¸RÓ@×FÑFÓH�ð×&Ñ&Ð'7Ô8ØŸ™ Ó)×0Ñ0°Ó>‘Að×(Ñ(¨Ô3Øð ×'Ñ'¨ Ô6Ø" hÑ.àŸ™ Ó)×0Ñ0°Ó>‘Að Ÿ™  iÓ0×7Ñ7¸ ÓE‘Að —H‘H˜S #Ó&×-Ñ-¨lÓ;�àˆ�‹ ðW#ðX €Nøôg òØ‹ðús˜E$Å$ E3Å2E3có—eZdZdZdZdZdZdZdZdZ dZ e «Z e ZeZdZdZdgZd ZdxZZdZdZd Zd „Zd „Zd „Zd„Zd„Zd„Zd$d„Z d„Z!d„Z"d„Z#d„Z$d„Z%d„Z&d„Z'd„Z(d„Z)d„Z*d„Z+d„Z,d„Z-d„Z.d „Z/d!„Z0d"„Z1d#„Z2y)%rz+Manage the invocation of a WSGI application)rrTFz1.0Nz500 Internal Server Error)z Content-Typez text/plains;A server error occurred. Please contact the administrator.rcó— |j«||j|j«|_|j «y#t t tf$rYy |j«Yy#|j«‚xYwxYw)zInvoke the applicationN) Ú setup_environrRÚstart_responseÚresultÚfinish_responseÚConnectionAbortedErrorÚBrokenPipeErrorÚConnectionResetErrorÚ handle_errorÚclose)ÚselfÚ applications r0ÚrunzBaseHandler.run€sv€ð Ø × Ñ Ô Ù% d§l¡l°D×4GÑ4GÓHˆDŒKØ × Ñ Õ "øÜ&¬Ô9MÐNò ñ ð ð Ø×!Ñ!Ö#øð à— ‘ ” Øýs$‚AAÁBÁBÁA/Á/BÂBcóò—|jj«x}|_|j«|j «|d<|j «|d<|j |d<|j|d<|j«|d<|j|d<|j|d<|j�|j|d <|jr*|jr|jd |j«yyy) z&Set up the environment for one requestz wsgi.inputz wsgi.errorsz wsgi.versionz wsgi.run_oncezwsgi.url_schemezwsgi.multithreadzwsgi.multiprocessNzwsgi.file_wrapperrK)Ú os_environÚcopyrRÚ 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)rgÚenvs r0r^zBaseHandler.setup_environ˜sê€ð"Ÿ_™_×1Ñ1Ó3Ð3ˆˆdŒlØ ×ÑÔà#'§>¡>Ó#3ˆˆLÑØ#'§?¡?Ó#4ˆˆMÑØ#'×#4Ñ#4ˆˆNÑØ#'×#5Ñ#5ˆˆOÑØ#'§?¡?Ó#4ˆÐ ÑØ#'×#8Ñ#8ˆÐ ÑØ#'×#9Ñ#9ˆÐ Ñ à × !Ñ !Ð -Ø'+×'=Ñ'=ˆCÐ#Ñ $à × Ò  $×"6Ò"6Ø �N‰NÐ,¨T×-AÑ-AÕ Bð#7Ð r2có6— |j«r|j«s2|jD]}|j|«Œ|j «|j «y#t |jd«r|jj «‚xYw)a>Send any iterable data, then close self and the iterable Subclasses intended for use in asynchronous servers will want to redefine this method, such that it sets up callbacks in the event loop to iterate over the data, and to call 'self.close()' once the response is finished. rfN)Úresult_is_fileÚsendfiler`ÚwriteÚfinish_contentrfÚhasattr©rgÚdatas r0razBaseHandler.finish_response­sv€ð Ø×&Ñ&Ô(°· ± ´Ø ŸKœK�DØ—J‘J˜tÕ$ð(à×#Ñ#Ô%ð �J‰J�Løð ô�t—{‘{ GÔ,Ø— ‘ ×!Ñ!Ô#Ø ús ‚AA%Á%3Bcó,—t|j«S)z Return the URL scheme being used)rrR©rgs r0rrzBaseHandler.get_schemeÇs€ä˜DŸL™LÓ)Ð)r2có´— t|j«}|dk(r#t|j«|jd<yy#t t tf$rYywxYw)z@Compute Content-Length or switch to chunked encoding if possiblerúContent-LengthN)Úlenr`ÚstrÚ bytes_sentÚheadersÚ TypeErrorÚAttributeErrorÚNotImplementedError)rgÚblockss r0Úset_content_lengthzBaseHandler.set_content_lengthÌsZ€ð ܘŸ™Ó%ˆFð�qŠyÜ14°T·_±_Ó1E�— ‘ Ð-Ñ.Øðøôœ.Ô)<Ð=ò Ù ð ús‚AÁAÁAcóB—d|jvr|j«yy)zqMake any necessary header changes or defaults Subclasses can extend this to add other defaults. r…N)r‰rŽrƒs r0Úcleanup_headerszBaseHandler.cleanup_headersÙs!€ð  4§<¡<Ñ /Ø × #Ñ #Õ %ð 0r2cóŽ—|r |jr‚ d}n|j� td«‚||_|j |«|_|j |d«}|j |« |D]B\}}|j |d«}|j |d«}t|«sŒ6Jd|›d|›d�«‚|jS#d}wxYw) z4'start_response()' callable as specified by PEP 3333NzHeaders already set!ÚStatusz Header namez Header valuezHop-by-hop header, 'z: z', not allowed) Ú headers_sentr‰ÚAssertionErrorÚstatusÚ headers_classÚ_convert_string_typeÚ_validate_statusrr})rgr•r‰Úexc_infoÚnameÚvals r0r_zBaseHandler.start_responseásæ€ñ ð Ø×$Ò$Øð%ð ‘Ø �\‰\Ð %Ü Ð!7Ó8Ð 8àˆŒ Ø×)Ñ)¨'Ó2ˆŒ Ø×*Ñ*¨6°8Ó<ˆØ ×јfÔ%à Û$‘ ��cØ×0Ñ0°°}ÓE�Ø×/Ñ/°°^ÓD�Ü(¨Õ.ðJØ-¨d¨V°2°c°U¸.ÐIóJÐ.ð%ð �z‰zÐøð! ‘ús „ CÃCcó˜—t|«dkr td«‚|ddj«s td«‚|ddk7r td«‚y)Néz$Status must be at least 4 characterséz(Status message must begin w/3-digit codeÚ z+Status message must have a space after code)r†r”Úisdigit)rgr•s r0r˜zBaseHandler._validate_statusûsT€Ü ˆv‹;˜Š?Ü Ð!GÓHÐ HØ�b�qˆz×!Ñ!Ô#Ü Ð!KÓLÐ LØ �!‰9˜Ò Ü Ð!NÓOÐ Oð r2cóp—t|«tur|Stdj|t |«««‚)zConvert/check value type.z!{0} must be of type str (got {1}))Útyper‡r”ÚformatÚrepr)rgÚvalueÚtitles r0r—z BaseHandler._convert_string_types4€ä �‹;œ#Ñ ØˆLÜØ /× 6Ñ 6°u¼dÀ5»kÓ Jó ð r2có:—|jrâ|j«rÑ|jd|j›d|j›d�j d««d|j vr>|jdttj««zj d««|jr=d|j vr.|jd|jzj d««y y y y |jd |jzj d««y ) z6Transmit version/status/date/server, via self._write()zHTTP/rŸz rLÚDatez Date: %s ÚServerz Server: %s z Status: %s N) rvÚclient_is_modernÚ_writeÚ http_versionr•rOr‰r1r"rwrƒs r0Ú send_preamblezBaseHandler.send_preamble sá€à × Ò Ø×$Ñ$Ô&Ø— ’ °×1BÓ1BÀ4Ç;Ã;ÐO×WÑWÐXdÓeÔfØ §¡Ñ-Ø—K‘KØ'Ô*:¼4¿9¹9»;Ó*GÑG×OÑOÐP\Ó]ôð×'Ò'¨H¸D¿L¹LÑ,HØ—K‘KÐ!1°D×4HÑ4HÑ!H× PÑ PÐQ]Ó ^Õ_ð-IÐ'ð 'ð �K‰KÐ)¨D¯K©KÑ7×?Ñ?À ÓMÕ Nr2có:—t|«tusJd«‚|js td«‚|js!t |«|_|j«n|xj t |«z c_|j|«|j«y)z+'write()' callable as specified by PEP 3333z)write() argument must be a bytes instancezwrite() before start_response()N) r¢Úbytesr•r”r“r†rˆÚ send_headersr«Ú_flushr€s r0r}zBaseHandler.writes~€ô�D‹zœUÑ"ð 8Ø 7ó 8Ð"ð�{Š{Ü Ð!BÓCÐ Cà×"Ò"ä! $›iˆDŒOØ × Ñ Õ à �OŠOœs 4›yÑ (�Oð � ‰ �DÔØ � ‰ � r2có—y)aPlatform-specific file transmission Override this method in subclasses to support platform-specific file transmission. It is only called if the application's return iterable ('self.result') is an instance of 'self.wsgi_file_wrapper'. This method should return a true value if it was able to actually transmit the wrapped file-like object using a platform-specific approach. It should return a false value if normal iteration should be used instead. An exception can be raised to indicate that transmission was attempted, but failed. NOTE: this method should call 'self.send_headers()' if 'self.headers_sent' is false and it is going to attempt direct transmission of the file. F©rƒs r0r|zBaseHandler.sendfile.s€ð$r2cóv—|js-|jjdd«|j«yy)z.Ensure headers and content have both been sentr…Ú0N)r“r‰rxr°rƒs r0r~zBaseHandler.finish_contentCs1€à× Ò ð �L‰L× #Ñ #Ð$4°cÔ :Ø × Ñ Õ à r2có— t|jd«r|jj«dx|_x|_x|_|_d|_d|_y#dx|_x|_x|_|_d|_d|_wxYw)z„Close the iterable (if needed) and reset all instance vars Subclasses may want to also drop the client connection. rfNrF)rr`rfr‰r•rRrˆr“rƒs r0rfzBaseHandler.closeMs€ð  ;Ü�t—{‘{ 7Ô+Ø— ‘ ×!Ñ!Ô#àFJÐ JˆDŒKÐ J˜$œ,Ð J¨¬°t´|؈DŒO°U Õ!2øðGKÐ JˆDŒKÐ J˜$œ,Ð J¨¬°t´|؈DŒO°U Õ!2ús ‚0AÁ,B cóÔ—|j«d|_|jr|j«r5|j «|j t |j««yy)z1Transmit headers to the client, via self._write()TN)r�r“rvrªr­r«r¯r‰rƒs r0r°zBaseHandler.send_headersZsP€à ×ÑÔØ ˆÔØ×!Ò! T×%:Ñ%:Ô%<Ø × Ñ Ô Ø �K‰Kœ˜dŸl™lÓ+Õ ,ð&=r2cóR—|j}|duxrt|j|«S)z@True if 'self.result' is an instance of 'self.wsgi_file_wrapper'N)ruÚ isinstancer`)rgÚwrappers r0r{zBaseHandler.result_is_filecs(€à×(Ñ(ˆØ˜dÐ"ÒF¤z°$·+±+¸gÓ'FÐFr2cóB—|jdj«dk7S)z,True if client can accept status and headersÚSERVER_PROTOCOLzHTTP/0.9)rRÚupperrƒs r0rªzBaseHandler.client_is_modernis €à�|‰|Ð-Ñ.×4Ñ4Ó6¸*ÑDÐDr2có¢— ddlm}|j«}||d|d|d|j|«|j «d}y#d}wxYw)z�Log the 'exc_info' tuple in the server log Subclasses may override to retarget the output or change its format. r)Úprint_exceptionréN)Ú tracebackr¿roÚtraceback_limitÚflush)rgr™r¿Ústderrs r0Ú log_exceptionzBaseHandler.log_exceptionnsR€ð Ý 1Ø—_‘_Ó&ˆF٠ؘ‘ ˜X a™[¨(°1©+Ø×$Ñ$ fô ð �L‰LŒNà‰Hø�t‰Hús ‚AA Á AcóÚ—|jtj««|js<|j |j |j «|_|j«yy)z>Log current error, and send error output to client if possibleN) rÅrMr™r“Ú error_outputrRr_r`rarƒs r0rezBaseHandler.handle_error~sN€à ×Ñœ3Ÿ<™<›>Ô*Ø× Ò Ø×+Ñ+¨D¯L©L¸$×:MÑ:MÓNˆDŒKØ × Ñ Õ "ð!r2có‚—||j|jddtj««|jgS)aZWSGI mini-app to create error output By default, this just uses the 'error_status', 'error_headers', and 'error_body' attributes to generate an output page. It can be overridden in a subclass to dynamically generate diagnostics, choose an appropriate message for the user's preferred language, etc. Note, however, that it's not recommended from a security perspective to spit out diagnostics to any old user; ideally, you should have to do something special to enable diagnostic output, which is why we don't include any here! N)Ú error_statusÚ error_headersrMr™Ú error_body)rgrRr_s r0rÇzBaseHandler.error_output†s4€ñ �t×(Ñ(¨×);Ñ);¹AÐ)>¼s¿|¹|»~ÔNØ—‘Ð Ð r2có—t‚)aOverride in subclass to buffer data for send to client It's okay if this method actually transmits the data; BaseHandler just separates write and flush operations for greater efficiency when the underlying system actually has such a distinction. ©rŒr€s r0r«zBaseHandler._write™s €ô"Ð!r2có—t‚)z¬Override in subclass to force sending of recent '_write()' calls It's okay if this method is a no-op (i.e., if '_write()' actually sends the data. rÍrƒs r0r±zBaseHandler._flush¢s €ô "Ð!r2có—t‚)z4Override in subclass to return suitable 'wsgi.input'rÍrƒs r0rnzBaseHandler.get_stdinªó€ä!Ð!r2có—t‚)z5Override in subclass to return suitable 'wsgi.errors'rÍrƒs r0rozBaseHandler.get_stderr®rÐr2có—t‚)z>Override in subclass to insert CGI variables in 'self.environ'rÍrƒs r0rmzBaseHandler.add_cgi_vars²rÐr2©N)3Ú__name__Ú __module__Ú __qualname__Ú__doc__rprsrtrqrvr¬rwr rkrrurr–rÂrÉrÊrËr•r`r“r‰rˆrir^rarrrŽr�r_r˜r—r­r}r|r~rfr°r{rªrÅrerÇr«r±rnrormr³r2r0rr^sø„Ù5ð€LØÐØÐØ€Mà€MØ€LØ€Oñ “€Jð$ÐØ€Mð€OØ.€LØ2Ð3€MØO€JðЀFˆVØ€LØ€GØ€Jòò0Cò*ò4*ò ò&óò4Pò ò Oòò*ò*ò ;ò-òGò Eò ò #ò!ò&"ò"ò"ò"ó"r2rcó8—eZdZdZ d d„Zd„Zd„Zd„Zd„Zd„Z y) r aqHandler that's just initialized with streams, environment, etc. This handler subclass is intended for synchronous HTTP/1.0 origin servers, and handles sending the entire response output, given the correct inputs. Usage:: handler = SimpleHandler( inp,out,err,env, multithread=False, multiprocess=True ) handler.run(app)cóX—||_||_||_||_||_||_yrÓ)ÚstdinÚstdoutrÄÚbase_envrsrt)rgrÚrÛrÄrRÚ multithreadÚ multiprocesss r0Ú__init__zSimpleHandler.__init__Äs0€ðˆŒ ؈Œ ؈Œ ؈Œ Ø +ˆÔØ!-ˆÕr2có—|jSrÓ)rÚrƒs r0rnzSimpleHandler.get_stdinÎs €Ø�z‰zÐr2có—|jSrÓ)rÄrƒs r0rozSimpleHandler.get_stderrÑs €Ø�{‰{Ðr2cóN—|jj|j«yrÓ)rRÚupdaterÜrƒs r0rmzSimpleHandler.add_cgi_varsÔs€Ø � ‰ ×јDŸM™MÕ*r2cóØ—|jj|«}|�|t|«k(ryddlm}|dt «||dx}r$|jj|«}||dx}rŒ#yy)Nr)Úwarnz9SimpleHandler.stdout.write() should not do partial writes)rÛr}r†ÚwarningsråÚDeprecationWarning)rgr�r`rås r0r«zSimpleHandler._write×sr€Ø—‘×"Ñ" 4Ó(ˆØ ˆ>˜V¤s¨4£yÒ0Ø Ý!Ù Ð HÜ ô à˜6˜7�mÐ#ˆdÐ#Ø—[‘[×&Ñ& tÓ,ˆFð˜6˜7�mÐ#ˆdÓ#r2cón—|jj«|jj|_yrÓ)rÛrÃr±rƒs r0r±zSimpleHandler._flushás#€Ø � ‰ ×ÑÔØ—k‘k×'Ñ'ˆ� r2N)TF) rÔrÕrÖr×rßrnrormr«r±r³r2r0r r ·s*„ñ ð(-ó.òòò+ò-ó(r2r có—eZdZdZdZy)r aÚCGI-like systems using input/output/error streams and environ mapping Usage:: handler = BaseCGIHandler(inp,out,err,env) handler.run(app) This handler class is useful for gateway protocols like ReadyExec and FastCGI, that have usable input/output/error streams and an environment mapping. It's also the base class for CGIHandler, which just uses sys.stdin, os.environ, and so on. The constructor also takes keyword arguments 'multithread' and 'multiprocess' (defaulting to 'True' and 'False' respectively) to control the configuration sent to the application. It sets 'origin_server' to False (to enable CGI-like output), and assumes that 'wsgi.run_once' is False. FN)rÔrÕrÖr×rvr³r2r0r r æs„ñð&�Mr2r có—eZdZdZdZiZd„Zy)r aéCGI-based invocation via sys.stdin/stdout/stderr and os.environ Usage:: CGIHandler().run(app) The difference between this class and BaseCGIHandler is that it always uses 'wsgi.run_once' of 'True', 'wsgi.multithread' of 'False', and 'wsgi.multiprocess' of 'True'. It does not take any initialization parameters, but always uses 'sys.stdin', 'os.environ', and friends. If you need to override any of these parameters, use BaseCGIHandler instead. Tc óÈ—tj|tjjtj jtj t«dd¬«y)NFT©rÝrÞ)r rßrMrÚÚbufferrÛrÄr rƒs r0rßzCGIHandler.__init__s?€Ü×ÑØ ”#—)‘)×"Ñ"¤C§J¡J×$5Ñ$5´s·z±zÜ ‹N¨¸Dð õ r2N©rÔrÕrÖr×rqrkrßr³r2r0r r þs„ñ ð€Mð€Jó r2r có—eZdZdZdZiZd„Zy)r aCGI-based invocation with workaround for IIS path bug This handler should be used in preference to CGIHandler when deploying on Microsoft IIS without having set the config allowPathInfo option (IIS>=7) or metabase allowPathInfoForScriptMappings (IIS<7). Tc ód—t«}|jdd«}|jdd«}|dzj|dz«r|t|«d|d<tj |t jjt jjt j|dd¬«y)Nr5rHr7Ú/FTrì) r rUrCr†r rßrMrÚrírÛrÄ)rgrRÚpathÚscripts r0rßzIISCGIHandler.__init__4s�€Ü“ˆØ�{‰{˜;¨Ó+ˆØ—‘˜]¨BÓ/ˆØ �‰H× Ñ  ¨¡Ô ,Ø#'¬¨F« ¨ Ð#5ˆG�KÑ Ü×ÑØ ”#—)‘)×"Ñ"¤C§J¡J×$5Ñ$5´s·z±zØ  °Tð õ r2Nrîr³r2r0r r s„ñð €MØ€Jó  r2r )r×Úutilrrrr‰rrMrQr"Ú__all__r$r%r1Ú __contains__rBrDr rr r r r r³r2r0Úr÷s�ðÙ5ç:Ñ:ÝçÓò €ò A€ ò8€ òò ÷�,ð ò Cò9÷xV"ñV"ôr ,(�Kô,(ô^�]ôô0 �ô ô