*j1USrSSKJrJrJr SSKJrJr SSKrSSK r SSK r /SQr /SQr /SQr S r1S 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)Headers_name_disallowed_reN) 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 7/opt/alt/python313/lib64/python3.13/wsgiref/handlers.pyformat_date_timer2sB-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 r1rErEsT q> CQ\\'2 Call66J C LL % A*:1QR5*ACr3c[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 LookupErrorosenvironitemsrEplatformgetlowerrDdecode)encescrSrFvsoftwares r1rr"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_environrSstart_responseresultfinish_responseConnectionAbortedErrorBrokenPipeErrorConnectionResetError handle_errorclose)self applications r1runBaseHandler.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_wrapperrL) os_environcopyrS add_cgi_vars get_stdin get_stderr wsgi_version wsgi_run_once get_schemewsgi_multithreadwsgi_multiprocesswsgi_file_wrapper origin_serverserver_software setdefault)rienvs r1r`BaseHandler.setup_environs"__1133l #'>>#3L#'??#4M#'#4#4N#'#5#5O#'??#4 #'#8#8 #'#9#9   ! ! -'+'='=C# $   $"6"6 NN,T-A-A B#7 r3cXUR5(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. rhN)result_is_filesendfilerbwritefinish_contentrhhasattrridatas r1rcBaseHandler.finish_responses~ &&((  KKDJJt$(##% JJL t{{G,, !!# s AA118B)c,[UR5$)z Return the URL scheme being used)rrSris r1ruBaseHandler.get_schemesDLL))r3c[UR5nUS:Xa#[UR5URS'gg![ [ [4a gf=f)z@Compute Content-Length or switch to chunked encoding if possiblerContent-LengthN)lenrbstr bytes_sentheaders TypeErrorAttributeErrorNotImplementedError)riblockss r1set_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 r1cleanup_headersBaseHandler.cleanup_headerss! 4<< /  # # % 0r3cU(aUR(aeSnOURb [S5eXlUR U5UlUR US5nUR U5 UR$!Snf=f)z4'start_response()' callable as specified by PEP 3333NzHeaders already set!Status) headers_sentrAssertionErrorstatus headers_class_convert_string_type_validate_statusr)rirrexc_infonamevals r1raBaseHandler.start_responses  $$%  \\ % !78 8 ))'2 **68< f% zz! s BBc[R"U5(a [S5e[U5S:a [ S5eUSSR 5(d [ S5eUSS:wa [ S5eg)Nz,Control characters are not allowed in statusz$Status must be at least 4 charactersz(Status message must begin w/3-digit code z+Status message must have a space after code)rsearch ValueErrorrrisdigit)rirs r1rBaseHandler._validate_statusst  % %f - -KL L v;? !GH Hbqz!!## !KL L !9  !NO O r3cr[U5[LaU$[SRU[ U555e)zConvert/check value type.z!{0} must be of type str (got {1}))typerrformatrepr)rivaluetitles r1r BaseHandler._convert_string_types4 ;# L / 6 6ud5k J  r3cfUR(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 rMDatez Date: %s Serverz Server: %s z Status: %s N) ryclient_is_modern_write http_versionrrPrr2r#rzrs r1 send_preambleBaseHandler.send_preamble s   $$&& 1B1B4;;OWWXdef-KK'*:499;*GGOOP\]''HDLL,HKK!1D4H4H!H P PQ] ^_-I' ' KK)DKK7?? M Nr3cUR(d [S5eUR(d![U5UlUR 5 OU=R[U5- slUR U5 UR5 g)z+'write()' callable as specified by PEP 3333zwrite() before start_response()N)rrrrr send_headersr_flushrs r1rBaseHandler.writes` {{ !BC C""!$iDO     OOs4y (O D r3cg)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 r1rBaseHandler.sendfile0s$r3cUR(d-URRSS5 UR5 gg)z.Ensure headers and content have both been sentr0N)rrr{rrs r1rBaseHandler.finish_contentEs1   LL # #$4c :     r3c"[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. rhNrF)rrbrhrrrSrrrs r1rhBaseHandler.closeOs  ;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)rrryrrrbytesrrs r1rBaseHandler.send_headers\sS  !!T%:%:%<%<    KKdll+ ,&=r3c\URnUSL=(a [URU5$)z@True if 'self.result' is an instance of 'self.wsgi_file_wrapper'N)rx isinstancerb)riwrappers r1rBaseHandler.result_is_filees(((d"Fz$++g'FFr3cBURSR5S:g$)z,True if client can accept status and headersSERVER_PROTOCOLzHTTP/0.9)rSupperrs r1rBaseHandler.client_is_modernks ||-.446*DDr3cSSKJn 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) tracebackrrrtraceback_limitflush)rirrstderrs r1 log_exceptionBaseHandler.log_exceptionpsR  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) rrNrr error_outputrSrarbrcrs r1rgBaseHandler.handle_errorsN 3<<>*  ++DLL$:M:MNDK  "!r3cU"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_headersrNr error_body)rirSras r1rBaseHandler.error_outputs4 t((););A)>s||~N  r3c[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 r1rBaseHandler._writes "!r3c[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 r1rBaseHandler._flushs "!r3c[e)z4Override in subclass to return suitable 'wsgi.input'rrs r1rqBaseHandler.get_stdin!!r3c[e)z5Override in subclass to return suitable 'wsgi.errors'rrs r1rrBaseHandler.get_stderrrr3c[e)z>Override in subclass to insert CGI variables in 'self.environ'rrs r1rpBaseHandler.add_cgi_varsrr3)rrSrrrbrN)5__name__ __module__ __qualname____firstlineno____doc__rsrvrwrtryrrzrrnrrxrrrrrrrrbrrrrkr`rcrurrrarrrrrrrhrrrrrgrrrrqrrrp__static_attributes__rr3r1r r ^s5LMMLO J$MO.L23MOJFVLGJ0C*4* &4P  O** ;-G E  #!&"""""r3r cB\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_envrvrw)rirrrrS multithread multiprocesss r1__init__SimpleHandler.__init__s$    +!-r3cUR$r)rrs r1rqSimpleHandler.get_stdins zzr3cUR$r)rrs r1rrSimpleHandler.get_stderrs {{r3cNURRUR5 gr)rSupdaterrs r1rpSimpleHandler.add_cgi_varss DMM*r3cURRU5nUbU[U5:XagSSKJn U"S[ 5 XS=n(a)URRU5nXS=n(aM(gg)Nr)warnz9SimpleHandler.stdout.write() should not do partial writes)rrrwarningsrDeprecationWarning)rirrbrs r1rSimpleHandler._writesq""4( >Vs4y0 ! H  7m#d#[[&&t,F7m#d##r3cnURR5 URRUlgr)rrrrs r1rSimpleHandler._flushs# kk'' r3)rrrrrrwrvN)TF) rrrrrrrqrrrprrrrr3r1r r s* (-.+-(r3r 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)rrrrrryrrr3r1r r s&Mr3r 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 rrNrbufferrrrrs r1rCGIHandler.__init__s? #))""CJJ$5$5szz ND  r3rN rrrrrrtrnrrrr3r1r r s MJ r3r 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)Nr6rIr8/FTr) rrVrDrr rrNrrrr)rirSpathscripts r1rIISCGIHandler.__init__6s{{;+]B/ H  , ,#'F #5GK  #))""CJJ$5$5szz T  r3rNrrr3r1r r s MJ  r3r )rutilrrrrrrrNrRr#__all__r%r&r2 __contains__rCrErr r r r r rr3r1rs5::1  A 8  , C9xX"X"v ,(K,(^]0