ó ù^‚Rc @sGdZddlmZddlmZmZmZddlmZddl Z ddl Z ddl Z dddd gZ ye Wnek rœd „Z nXd d d ddddgZeddddddddddddg Zd„Zdfd„ƒYZdefd „ƒYZdefd!„ƒYZd efd"„ƒYZdS(#s/Base classes for server/gateway implementationsiÿÿÿÿ(t StringType(t FileWrappert guess_schemet is_hop_by_hop(tHeadersNt BaseHandlert SimpleHandlertBaseCGIHandlert CGIHandlercCs+i}x|D]\}}|||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. N(tresult_is_filetsendfileR3twritetfinish_contentR6(R7tdata((s&/usr/lib/python2.7/wsgiref/handlers.pyR4us cCs t|jƒS(s Return the URL scheme being used(RR1(R7((s&/usr/lib/python2.7/wsgiref/handlers.pyRB†scCsZyt|jƒ}Wntttfk r/n'X|dkrVt|jƒ|jdLog current error, and send error output to client if possibleN( RytsysRaR[t error_outputR1R2R3R4(R7((s&/usr/lib/python2.7/wsgiref/handlers.pyR5-s cCs'||j|jtjƒƒ|jgS(sZWSGI 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! (t error_statust error_headersRzRat error_body(R7R1R2((s&/usr/lib/python2.7/wsgiref/handlers.pyR{5s cCs t‚dS(sOverride 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. N(RS(R7RO((s&/usr/lib/python2.7/wsgiref/handlers.pyRgHscCs t‚dS(s¬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. N(RS(R7((s&/usr/lib/python2.7/wsgiref/handlers.pyRkQscCs t‚dS(s4Override in subclass to return suitable 'wsgi.input'N(RS(R7((s&/usr/lib/python2.7/wsgiref/handlers.pyR>YscCs t‚dS(s5Override in subclass to return suitable 'wsgi.errors'N(RS(R7((s&/usr/lib/python2.7/wsgiref/handlers.pyR?]scCs t‚dS(s>Override in subclass to insert CGI variables in 'self.environ'N(RS(R7((s&/usr/lib/python2.7/wsgiref/handlers.pyR=as(iiN(s Content-Types text/plain(6t__name__t __module__t__doc__R@RoRCRDRlRARGRhRFRHR tosR1R R;RRERR`RvR|R}R~R_R3R[RVRUR9R0R4RBRXRYR2RiRMRLRNR6RjRKRfRyR5R{RgRkR>R?R=(((s&/usr/lib/python2.7/wsgiref/handlers.pyR*sT                   cBsJeZdZeed„Zd„Zd„Zd„Zd„Z d„Z RS(sqHandler 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)cCs:||_||_||_||_||_||_dS(N(tstdintstdoutRxtbase_envRCRD(R7RƒR„RxR1t multithreadt multiprocess((s&/usr/lib/python2.7/wsgiref/handlers.pyt__init__ss      cCs|jS(N(Rƒ(R7((s&/usr/lib/python2.7/wsgiref/handlers.pyR>}scCs|jS(N(Rx(R7((s&/usr/lib/python2.7/wsgiref/handlers.pyR?€scCs|jj|jƒdS(N(R1tupdateR…(R7((s&/usr/lib/python2.7/wsgiref/handlers.pyR=ƒscCs#|jj|ƒ|jj|_dS(N(R„RMRg(R7RO((s&/usr/lib/python2.7/wsgiref/handlers.pyRg†scCs |jjƒ|jj|_dS(N(R„RwRk(R7((s&/usr/lib/python2.7/wsgiref/handlers.pyRkŠs ( RR€RRoRlRˆR>R?R=RgRk(((s&/usr/lib/python2.7/wsgiref/handlers.pyRfs     cBseZdZeZRS(sÚ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. (RR€RRlRG(((s&/usr/lib/python2.7/wsgiref/handlers.pyRscBs#eZdZeZiZd„ZRS(sé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. c CsAtj|tjtjtjttjj ƒƒdt dt ƒdS(NR†R‡( RRˆRzRƒR„RxR R‚R1R RlRo(R7((s&/usr/lib/python2.7/wsgiref/handlers.pyRˆ¾s*(RR€RRoRAR;Rˆ(((s&/usr/lib/python2.7/wsgiref/handlers.pyR§s(RttypesRtutilRRRRVRRzR‚R!t__all__R t NameErrorR#RFR$R/RRRR(((s&/usr/lib/python2.7/wsgiref/handlers.pyts&$   ÿ=)