ž ¬ÿf˜Pc @spdZddlmZmZmZddlmZddlZddlZddl Z dddd d d gZ d d dddddgZ e ddddddddddddg Z dd „Zd!d"d#d$d%d&d'd(d)d*h jZd+d,„Zd-d „ZGd.d„dƒZGd/d„deƒZGd0d„deƒZGd1d „d eƒZGd2d „d eƒZdS(3u/Base classes for server/gateway implementationsi(u FileWrapperu guess_schemeu is_hop_by_hop(uHeadersiNu BaseHandleru SimpleHandleruBaseCGIHandleru CGIHandleru IISCGIHandleru read_environuMonuTueuWeduThuuFriuSatuSunuJanuFebuMaruApruMayuJunuJuluAuguSepuOctuNovuDecc CsOtj|ƒ\ }}}}}}}}} dt||t|||||fS(Nu#%s, %02d %3s %4d %02d:%02d:%02d GMT(utimeugmtimeu _weekdaynameu _monthname( u timestampuyearumonthudayuhhummussuwduyuz((u5/opt/alt/python33/lib64/python3.3/wsgiref/handlers.pyuformat_date_times*uformat_date_timeu SCRIPT_NAMEu PATH_INFOu QUERY_STRINGuREQUEST_METHODu AUTH_TYPEu CONTENT_TYPEuCONTENT_LENGTHuHTTPSu REMOTE_USERu REMOTE_IDENTcCsMt|ƒpL|jdƒpL|jdƒpL|jdƒoLt|dd…ƒS(NuHTTP_uSSL_u REDIRECT_i (u _is_requestu startswithu_needs_transcode(uk((u5/opt/alt/python33/lib64/python3.3/wsgiref/handlers.pyu_needs_transcodes*u_needs_transcodec CsYtjƒ}d}ydjd|ƒWntk r@d}YnXi}x tjjƒD]ú\}}t|ƒrGtjdkr)tjj ddƒj ƒ}|j dƒrÃ|jdƒj dƒ}qD|j d ƒrÕqD|j d ƒr d |kr |jdƒj dƒ}qD|j|dƒj dƒ}qG|j||ƒj dƒ}n|||u BaseHandleru+Manage the invocation of a WSGI applicationiiu1.0u500 Internal Server Erroru Content-Typeu text/plains;A server error occurred. Please contact the administrator.cCsey0|jƒ||j|jƒ|_|jƒWn.y|jƒWn|jƒ‚YnXYnXdS(uInvoke the applicationN(u setup_environuenvironustart_responseuresultufinish_responseu handle_erroruclose(uselfu application((u5/opt/alt/python33/lib64/python3.3/wsgiref/handlers.pyurun€s  uBaseHandler.runcCsÏ|jjƒ}|_|jƒ|jƒ|d<|jƒ|d<|j|d<|j|d<|jƒ|d<|j |d<|j |d<|j d k r£|j |dSend 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(uresult_is_fileusendfileuresultuwriteufinish_contentuclose(uselfudata((u5/opt/alt/python33/lib64/python3.3/wsgiref/handlers.pyufinish_response©s uBaseHandler.finish_responsecCs t|jƒS(u Return the URL scheme being used(u guess_schemeuenviron(uself((u5/opt/alt/python33/lib64/python3.3/wsgiref/handlers.pyu get_schemeºsuBaseHandler.get_schemec Cs[yt|jƒ}Wntttfk r0Yn'X|dkrWt|jƒ|jdLog current error, and send error output to client if possibleN( u log_exceptionusysuexc_infou headers_sentu error_outputuenvironustart_responseuresultufinish_response(uself((u5/opt/alt/python33/lib64/python3.3/wsgiref/handlers.pyu handle_errorks uBaseHandler.handle_errorcCs0||j|jdd…tjƒƒ|jgS(uZWSGI 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(u error_statusu error_headersusysuexc_infou error_body(uselfuenvironustart_response((u5/opt/alt/python33/lib64/python3.3/wsgiref/handlers.pyu error_outputss &uBaseHandler.error_outputcCs t‚dS(uOverride 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(uNotImplementedError(uselfudata((u5/opt/alt/python33/lib64/python3.3/wsgiref/handlers.pyu_write†suBaseHandler._writecCs t‚dS(u¬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(uNotImplementedError(uself((u5/opt/alt/python33/lib64/python3.3/wsgiref/handlers.pyu_flush�suBaseHandler._flushcCs t‚dS(u4Override in subclass to return suitable 'wsgi.input'N(uNotImplementedError(uself((u5/opt/alt/python33/lib64/python3.3/wsgiref/handlers.pyu get_stdin—suBaseHandler.get_stdincCs t‚dS(u5Override in subclass to return suitable 'wsgi.errors'N(uNotImplementedError(uself((u5/opt/alt/python33/lib64/python3.3/wsgiref/handlers.pyu get_stderr›suBaseHandler.get_stderrcCs t‚dS(u>Override in subclass to insert CGI variables in 'self.environ'N(uNotImplementedError(uself((u5/opt/alt/python33/lib64/python3.3/wsgiref/handlers.pyu add_cgi_varsŸsuBaseHandler.add_cgi_varsN(iiTF(u Content-Typeu text/plain(5u__name__u __module__u __qualname__u__doc__u wsgi_versionuTrueuwsgi_multithreaduwsgi_multiprocessuFalseu wsgi_run_onceu origin_serveru http_versionuNoneuserver_softwareu read_environu os_environu FileWrapperuwsgi_file_wrapperuHeadersu headers_classutraceback_limitu error_statusu error_headersu error_bodyustatusuresultu headers_sentuheadersu bytes_senturunu setup_environufinish_responseu get_schemeuset_content_lengthucleanup_headersustart_responseu_convert_string_typeu send_preambleuwriteusendfileufinish_contentucloseu send_headersuresult_is_fileuclient_is_modernu log_exceptionu handle_erroru error_outputu_writeu_flushu get_stdinu get_stderru add_cgi_vars(u __locals__((u5/opt/alt/python33/lib64/python3.3/wsgiref/handlers.pyu BaseHandler^sV                    cBsh|EeZdZdZdddd„Zdd„Zdd„Zdd „Z d d „Z d d „Z dS(u SimpleHandleruqHandler 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(ustdinustdoutustderrubase_envuwsgi_multithreaduwsgi_multiprocess(uselfustdinustdoutustderruenvironu multithreadu multiprocess((u5/opt/alt/python33/lib64/python3.3/wsgiref/handlers.pyu__init__±s      uSimpleHandler.__init__cCs|jS(N(ustdin(uself((u5/opt/alt/python33/lib64/python3.3/wsgiref/handlers.pyu get_stdin»suSimpleHandler.get_stdincCs|jS(N(ustderr(uself((u5/opt/alt/python33/lib64/python3.3/wsgiref/handlers.pyu get_stderr¾suSimpleHandler.get_stderrcCs|jj|jƒdS(N(uenvironuupdateubase_env(uself((u5/opt/alt/python33/lib64/python3.3/wsgiref/handlers.pyu add_cgi_varsÁsuSimpleHandler.add_cgi_varscCs|jj|ƒdS(N(ustdoutuwrite(uselfudata((u5/opt/alt/python33/lib64/python3.3/wsgiref/handlers.pyu_writeÄsuSimpleHandler._writecCs |jjƒ|jj|_dS(N(ustdoutuflushu_flush(uself((u5/opt/alt/python33/lib64/python3.3/wsgiref/handlers.pyu_flushÇs uSimpleHandler._flushNTF( u__name__u __module__u __qualname__u__doc__uTrueuFalseu__init__u get_stdinu get_stderru add_cgi_varsu_writeu_flush(u __locals__((u5/opt/alt/python33/lib64/python3.3/wsgiref/handlers.pyu SimpleHandler¤s     cBs |EeZdZdZdZdS(uBaseCGIHandleruÚ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. NF(u__name__u __module__u __qualname__u__doc__uFalseu origin_server(u __locals__((u5/opt/alt/python33/lib64/python3.3/wsgiref/handlers.pyuBaseCGIHandlerÌscBs2|EeZdZdZdZiZdd„ZdS(u CGIHandlerué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 Cs;tj|tjjtjjtjtƒddddƒdS(Nu multithreadu multiprocessFT( uBaseCGIHandleru__init__usysustdinubufferustdoutustderru read_environuFalseuTrue(uself((u5/opt/alt/python33/lib64/python3.3/wsgiref/handlers.pyu__init__ûsuCGIHandler.__init__NT(u__name__u __module__u __qualname__u__doc__uTrueu wsgi_run_onceu os_environu__init__(u __locals__((u5/opt/alt/python33/lib64/python3.3/wsgiref/handlers.pyu CGIHandleräscBs2|EeZdZdZdZiZdd„ZdS(u IISCGIHandleruCGI-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). c Cs™tƒ}|jddƒ}|jddƒ}|dj|dƒra|t|ƒd…|ds($     <ÿG(