eTSrSSKJrJrJr SSKJr SSKrSSKrSSK r /SQr /SQr /SQr S r 1S kRrS rS r"S S5r"SS\5r"SS\5r"SS\5r"SS\5rg)z/Base classes for server/gateway implementations) FileWrapper guess_scheme is_hop_by_hop)HeadersN) BaseHandler SimpleHandlerBaseCGIHandler CGIHandler IISCGIHandler read_environ)MonTueWedThuFriSatSun) NJanFebMarAprMayJunJulAugSepOctNovDecc j[R"U5u pp4pVpxn S[UU[UXXV4-$)Nz#%s, %02d %3s %4d %02d:%02d:%02d GMT)timegmtime _weekdayname _monthname) timestampyearmonthdayhhmmsswdyzs 6/opt/imh/python3.13/lib/python3.13/wsgiref/handlers.pyformat_date_timer1sB-1[[-C*D"" 0R#z%0$B4 > HTTPS AUTH_TYPE PATH_INFO REMOTE_USER SCRIPT_NAME CONTENT_TYPE QUERY_STRING REMOTE_IDENTCONTENT_LENGTHREQUEST_METHODc[U5=(dV URS5=(d> URS5=(d& URS5=(a [USS5$)NHTTP_SSL_ REDIRECT_ ) _is_request startswith_needs_transcode)ks r0rDrDsT q> CQ\\'2 Call66J C LL % A*:1QR5*ACr2c[R"5nSnSRSU5 0n[R R 5GH*up4[U5(Ga[RS:Xa[R RSS5R5nURS5(a!URS5RS5nOURS 5(aOURS 5(a'S U;a!URS5RS5nOBURUS5RS5nO URX5RS5nXBU'GM- U$![a SnGN`f=f) z'Read environment, fixing HTTP variablessurrogateescapezutf-8replacewin32SERVER_SOFTWAREzmicrosoft-iis/ iso-8859-1zapache/z simplehttp/zpython/3) sysgetfilesystemencodingencode LookupErrorosenvironitemsrDplatformgetlowerrCdecode)encescrRrEvsoftwares r0r r "sW # # %C C '3G    " A  ||w&::>>*;R@FFH&&'788)00>A((33 '' 66"h.)00>A i077 EA HHS&--l; W#X Ng sE<< F  F c \rSrSrSrSrSrSrSrSr Sr Sr \ "5r \r\rSrSrS /rS rS=rrSrSrS rS rS rSrSrSrSr S&Sjr!Sr"Sr#Sr$Sr%Sr&Sr'Sr(Sr)Sr*Sr+Sr,Sr-Sr.S r/S!r0S"r1S#r2S$r3S%r4g)'r^z+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.rcUR5 U"URUR5UlUR 5 g![ [ [4a g UR5 g! UR5 e=f=f)zInvoke the applicationN) setup_environrRstart_responseresultfinish_responseConnectionAbortedErrorBrokenPipeErrorConnectionResetError handle_errorclose)self applications r0runBaseHandler.runsv     %dllD4G4GHDK  "&9MN    !!#  s$AABBA00BBcURR5=olUR5 UR 5US'UR 5US'UR US'URUS'UR5US'URUS'URUS'URbURUS 'UR(a/UR(aURS UR5 ggg) z&Set up the environment for one requestz wsgi.inputz wsgi.errorsz wsgi.versionz wsgi.run_oncezwsgi.url_schemezwsgi.multithreadzwsgi.multiprocessNzwsgi.file_wrapperrK) os_environcopyrR add_cgi_vars get_stdin get_stderr wsgi_version wsgi_run_once get_schemewsgi_multithreadwsgi_multiprocesswsgi_file_wrapper origin_serverserver_software setdefault)rhenvs r0r_BaseHandler.setup_environs"__1133l #'>>#3L#'??#4M#'#4#4N#'#5#5O#'??#4 #'#8#8 #'#9#9   ! ! -'+'='=C# $   $"6"6 NN,T-A-A B#7 r2cXUR5(aUR5(d4URHnURU5 M UR 5 UR 5 g! [ URS5(aURR 5 e=f)aSend 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. rgN)result_is_filesendfilerawritefinish_contentrghasattrrhdatas r0rbBaseHandler.finish_responses~ &&((  KKDJJt$(##% JJL t{{G,, !!# s AA118B)c,[UR5$)z Return the URL scheme being used)rrRrhs r0rtBaseHandler.get_schemesDLL))r2c[UR5nUS:Xa#[UR5URS'gg![ [ [4a gf=f)z@Compute Content-Length or switch to chunked encoding if possiblerContent-LengthN)lenrastr bytes_sentheaders TypeErrorAttributeErrorNotImplementedError)rhblockss r0set_content_lengthBaseHandler.set_content_lengthsZ %Fqy14T__1E -..)<=   sAAAcFSUR;aUR5 gg)zaMake any necessary header changes or defaults Subclasses can extend this to add other defaults. rN)rrrs r0cleanup_headersBaseHandler.cleanup_headerss! 4<< /  # # % 0r2cU(aUR(aeSnOURb [S5eXlUR U5UlUR US5nUR U5 UHGupEUR US5nUR US5n[U5(dM;SUSUS35e UR$!Snf=f) z4'start_response()' callable as specified by PEP 3333NzHeaders already set!Statusz Header namez Header valuezHop-by-hop header, 'z: z', not allowed) headers_sentrAssertionErrorstatus headers_class_convert_string_type_validate_statusrr)rhrrexc_infonamevals r0r`BaseHandler.start_responses  $$%  \\ % !78 8 ))'2 **68< f% $ 00}E//^D(..J-dV2cU.IJ.% zz! s CCc[U5S:a [S5eUSSR5(d [S5eUSS:wa [S5eg)Nz$Status must be at least 4 charactersz(Status message must begin w/3-digit code z+Status message must have a space after code)rrisdigit)rhrs r0rBaseHandler._validate_statussW v;? !GH Hbqz!!## !KL L !9  !NO O r2cr[U5[LaU$[SRU[ U555e)zConvert/check value type.z!{0} must be of type str (got {1}))typerrformatrepr)rhvaluetitles r0r BaseHandler._convert_string_types4 ;# L / 6 6ud5k J  r2cfUR(aUR5(aURSUR<SUR<S3R S55 SUR ;a?URS[[R"55-R S55 UR(a?SUR ;a.URSUR-R S55 g g g g URS UR-R S55 g ) z6Transmit version/status/date/server, via self._write()zHTTP/rz rLDatez Date: %s Serverz Server: %s z Status: %s N) rxclient_is_modern_write http_versionrrOrr1r"ryrs r0 send_preambleBaseHandler.send_preamble s   $$&& 1B1B4;;OWWXdef-KK'*:499;*GGOOP\]''HDLL,HKK!1D4H4H!H P PQ] ^_-I' ' KK)DKK7?? M Nr2cP[U5[LdS5eUR(d [S5eUR(d![ U5UlUR5 OU=R [ U5- slURU5 UR5 g)z+'write()' callable as specified by PEP 3333z)write() argument must be a bytes instancezwrite() before start_response()N) rbytesrrrrr send_headersr_flushrs r0rBaseHandler.writes~DzU" 8 7 8"{{ !BC C""!$iDO     OOs4y (O D r2cg)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. Frs r0rBaseHandler.sendfile.s$r2cUR(d-URRSS5 UR5 gg)z.Ensure headers and content have both been sentr0N)rrrzrrs r0rBaseHandler.finish_contentCs1   LL # #$4c :     r2c"[URS5(aURR5 S=Ul=Ul=UlUlSUlSUlg!S=Ul=Ul=UlUlSUlSUlf=f)ztClose the iterable (if needed) and reset all instance vars Subclasses may want to also drop the client connection. rgNrF)rrargrrrRrrrs r0rgBaseHandler.closeMs  ;t{{7++ !!#FJ JDK J$, Jt|DOU!2GK JDK J$, Jt|DOU!2s 5A"",BcUR5 SUlUR(aUR5(a5UR 5 UR [ UR55 gg)z1Transmit headers to the client, via self._write()TN)rrrxrrrrrrs r0rBaseHandler.send_headersZsS  !!T%:%:%<%<    KKdll+ ,&=r2c\URnUSL=(a [URU5$)z@True if 'self.result' is an instance of 'self.wsgi_file_wrapper'N)rw isinstancera)rhwrappers r0r~BaseHandler.result_is_filecs(((d"Fz$++g'FFr2cBURSR5S:g$)z,True if client can accept status and headersSERVER_PROTOCOLzHTTP/0.9)rRupperrs r0rBaseHandler.client_is_modernis ||-.446*DDr2cSSKJn UR5nU"USUSUSURU5 UR 5 Sng!Snf=f)zqLog the 'exc_info' tuple in the server log Subclasses may override to retarget the output or change its format. r)print_exceptionrN) tracebackrrqtraceback_limitflush)rhrrstderrs r0 log_exceptionBaseHandler.log_exceptionnsR  1__&F  Xa[(1+$$f  LLNHtHs AA AcUR[R"55 UR(d<UR UR UR 5UlUR5 gg)z>Log current error, and send error output to client if possibleN) rrMrr error_outputrRr`rarbrs r0rfBaseHandler.handle_error~sN 3<<>*  ++DLL$:M:MNDK  "!r2cU"URURSS[R"55 UR/$)aWSGI 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)rhrRr`s r0rBaseHandler.error_outputs4 t((););A)>s||~N  r2c[e)zOverride 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. rrs r0rBaseHandler._writes "!r2c[e)zOverride 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. rrs r0rBaseHandler._flushs "!r2c[e)z4Override in subclass to return suitable 'wsgi.input'rrs r0rpBaseHandler.get_stdin!!r2c[e)z5Override in subclass to return suitable 'wsgi.errors'rrs r0rqBaseHandler.get_stderrrr2c[e)z>Override in subclass to insert CGI variables in 'self.environ'rrs r0roBaseHandler.add_cgi_varsrr2)rrRrrrarN)5__name__ __module__ __qualname____firstlineno____doc__rrrurvrsrxrryr rmrrwrrrrrrrrarrrrjr_rbrtrrr`rrrrrrrgrr~rrrfrrrrprqro__static_attributes__rr2r0rr^s5LMMLO J$MO.L23MOJFVLGJ0C*4* &4P  O** ;-G E  #!&"""""r2rcB\rSrSrSrS SjrSrSrSrSr Sr S r g ) r iaUHandler 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)cLXlX lX0lX@lXPlX`lgr)stdinstdoutrbase_envrurv)rhrrrrR multithread multiprocesss r0__init__SimpleHandler.__init__s$    +!-r2cUR$r)rrs r0rpSimpleHandler.get_stdins zzr2cUR$r)rrs r0rqSimpleHandler.get_stderrs {{r2cNURRUR5 gr)rRupdaterrs r0roSimpleHandler.add_cgi_varss DMM*r2cURRU5nUbU[U5:XagSSKJn U"S[ 5 XS=n(a)URRU5nXS=n(aM(gg)Nr)warnz9SimpleHandler.stdout.write() should not do partial writes)rrrwarningsrDeprecationWarning)rhrrars r0rSimpleHandler._writesq""4( >Vs4y0 ! H  7m#d#[[&&t,F7m#d##r2cnURR5 URRUlgr)rrrrs r0rSimpleHandler._flushs# kk'' r2)rrrrrrvruN)TF) rrrrrrrprqrorrrrr2r0r r s* (-.+-(r2r c\rSrSrSrSrSrg)r iaCGI-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. FrN)rrrrrrxrrr2r0r r s&Mr2r c&\rSrSrSrSr0rSrSrg)r iaCGI-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 [RU[RR[R R[R [5SSS9 g)NFTrr)r rrMrbufferrrr rs r0rCGIHandler.__init__s? #))""CJJ$5$5szz ND  r2rN rrrrrrsrmrrrr2r0r r s MJ r2r c&\rSrSrSrSr0rSrSrg)r izCGI-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 h[5nURSS5nURSS5nUS-RUS-5(aU[U5SUS'[R U[ RR[ RR[ RUSSS9 g)Nr5rHr7/FTr) r rUrCrr rrMrrrr)rhrRpathscripts r0rIISCGIHandler.__init__4s{{;+]B/ H  , ,#'F #5GK  #))""CJJ$5$5szz T  r2rNrrr2r0r r s MJ  r2r )rutilrrrrrrMrQr"__all__r$r%r1 __contains__rBrDr rr r r r rr2r0rs5::  A 8  , C9xV"V"r ,(K,(^]0