%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib64/python2.7/site-packages/tornado/
Upload File :
Create Path :
Current File : //usr/lib64/python2.7/site-packages/tornado/wsgi.pyo

�
��L]c@�s�dZddlmZmZmZmZddlZddlmZddl	Z	ddl
mZddl	mZddl	m
Z
ddlmZdd	l	mZdd
lmZddlmZyddljZWnek
r�ddlZnXeekrd�Zd
�Znd�Zd�Zdejfd��YZe�Zej d�de
j"fd��YZ#de$fd��YZ%de$fd��YZ&de$fd��YZ'e
j(Z)dS(s�WSGI support for the Tornado web framework.

WSGI is the Python standard for web servers, and allows for interoperability
between Tornado and other Python web frameworks and servers.  This module
provides WSGI support in two ways:

* `WSGIAdapter` converts a `tornado.web.Application` to the WSGI application
  interface.  This is useful for running a Tornado app on another
  HTTP server, such as Google App Engine.  See the `WSGIAdapter` class
  documentation for limitations that apply.
* `WSGIContainer` lets you run other WSGI applications and frameworks on the
  Tornado HTTP server.  For example, with this class you can mix Django
  and Tornado handlers in a single server.
i(tabsolute_importtdivisiontprint_functiontwith_statementN(tBytesIO(tFuture(tescape(thttputil(t
access_log(tweb(t
native_str(tunicode_typecC�s
|jd�S(Ntlatin1(tdecode(ts((s2/usr/lib64/python2.7/site-packages/tornado/wsgi.pytto_wsgi_str8scC�s
|jd�S(NR(tencode(R((s2/usr/lib64/python2.7/site-packages/tornado/wsgi.pyt
from_wsgi_str<scC�s|S(N((R((s2/usr/lib64/python2.7/site-packages/tornado/wsgi.pyR@scC�s|S(N((R((s2/usr/lib64/python2.7/site-packages/tornado/wsgi.pyRDstWSGIApplicationcB�seZdZd�ZRS(s�A WSGI equivalent of `tornado.web.Application`.

    .. deprecated:: 4.0

       Use a regular `.Application` and wrap it in `WSGIAdapter` instead.
    cC�st|�||�S(N(tWSGIAdapter(tselftenvirontstart_response((s2/usr/lib64/python2.7/site-packages/tornado/wsgi.pyt__call__Ps(t__name__t
__module__t__doc__R(((s2/usr/lib64/python2.7/site-packages/tornado/wsgi.pyRIst_WSGIConnectioncB�s>eZd�Zd�Zddd�Zdd�Zd�ZRS(cC�sC||_||_||_g|_t|_d|_d|_dS(N(	tmethodRtcontextt
_write_buffertFalset	_finishedtNonet_expected_content_remainingt_error(RRRR((s2/usr/lib64/python2.7/site-packages/tornado/wsgi.pyt__init__[s						cC�sdS(N((Rtcallback((s2/usr/lib64/python2.7/site-packages/tornado/wsgi.pytset_close_callbackdscC�s�|jdkrd|_n+d|kr=t|d�|_n	d|_|jd|j|jfg|j�D]$\}}t|�t|�f^ql�|dk	r�|j	||�n|dk	r�|�nt
S(NtHEADisContent-Lengths%s %s(RR"tintR!Rtcodetreasontget_allR
twritet
_dummy_future(Rt
start_linetheaderstchunkR%tktv((s2/usr/lib64/python2.7/site-packages/tornado/wsgi.pyt
write_headersis	8
cC�s~|jdk	rT|jt|�8_|jdkrTtjd�|_|j�qTn|jj|�|dk	rz|�ntS(Nis,Tried to write more data than Content-Length(	R"R!tlenRtHTTPOutputErrorR#RtappendR-(RR0R%((s2/usr/lib64/python2.7/site-packages/tornado/wsgi.pyR,ys
cC�sP|jdk	rC|jdkrCtjd|j�|_|j�nt|_dS(Nis0Tried to write %d bytes less than Content-Length(R"R!RR5R#tTrueR (R((s2/usr/lib64/python2.7/site-packages/tornado/wsgi.pytfinish�sN(RRR$R&R!R3R,R8(((s2/usr/lib64/python2.7/site-packages/tornado/wsgi.pyRZs
			t_WSGIRequestContextcB�seZd�Zd�ZRS(cC�s||_||_dS(N(t	remote_iptprotocol(RR:R;((s2/usr/lib64/python2.7/site-packages/tornado/wsgi.pyR$�s	cC�s|jS(N(R:(R((s2/usr/lib64/python2.7/site-packages/tornado/wsgi.pyt__str__�s(RRR$R<(((s2/usr/lib64/python2.7/site-packages/tornado/wsgi.pyR9�s	RcB�s eZdZd�Zd�ZRS(sConverts a `tornado.web.Application` instance into a WSGI application.

    Example usage::

        import tornado.web
        import tornado.wsgi
        import wsgiref.simple_server

        class MainHandler(tornado.web.RequestHandler):
            def get(self):
                self.write("Hello, world")

        if __name__ == "__main__":
            application = tornado.web.Application([
                (r"/", MainHandler),
            ])
            wsgi_app = tornado.wsgi.WSGIAdapter(application)
            server = wsgiref.simple_server.make_server('', 8888, wsgi_app)
            server.serve_forever()

    See the `appengine demo
    <https://github.com/tornadoweb/tornado/tree/stable/demos/appengine>`_
    for an example of using this module to run a Tornado app on Google
    App Engine.

    In WSGI mode asynchronous methods are not supported.  This means
    that it is not possible to use `.AsyncHTTPClient`, or the
    `tornado.auth` or `tornado.websocket` modules.

    .. versionadded:: 4.0
    c�s1t�t�r$�fd�|_n	�|_dS(Nc�stjj�|�S(N(R	tApplicationR(trequest(tapplication(s2/usr/lib64/python2.7/site-packages/tornado/wsgi.pyt<lambda>�s	(t
isinstanceRR?(RR?((R?s2/usr/lib64/python2.7/site-packages/tornado/wsgi.pyR$�sc
C�s|d}tjt|jdd���}|tjt|jdd���7}|jd�rt|d|d7}ntj�}|jd�r�|d|d<n|jd	�r�|d	|d
<nx>|D]6}|jd�r�||||djd
d�<q�q�W|jd
�r0|djt	|d
��}nd}|d}|jdd�}	|jd�rn|d}
n
|d}
t
||t|	|��}tj||dd|d|d|
d|�}|j
�|j|�|jr�|j�n|jstd��n|jS(NtREQUEST_METHODtSCRIPT_NAMEtt	PATH_INFOtQUERY_STRINGt?tCONTENT_TYPEsContent-TypetCONTENT_LENGTHsContent-LengthtHTTP_it_t-s
wsgi.inputswsgi.url_schemetREMOTE_ADDRt	HTTP_HOSTtSERVER_NAMEsHTTP/1.1R/tbodythostt
connections$request did not finish synchronously(turllib_parsetquoteRtgetRtHTTPHeaderst
startswithtreplacetreadR(RR9tHTTPServerRequestt_parse_bodyR?R#R t	ExceptionR(
RRRRturiR/tkeyRPR;R:RQRRR>((s2/usr/lib64/python2.7/site-packages/tornado/wsgi.pyR�sD
!%
%



	

		(RRRR$R(((s2/usr/lib64/python2.7/site-packages/tornado/wsgi.pyR�s	t
WSGIContainercB�s8eZdZd�Zd�Zed��Zd�ZRS(s�Makes a WSGI-compatible function runnable on Tornado's HTTP server.

    .. warning::

       WSGI is a *synchronous* interface, while Tornado's concurrency model
       is based on single-threaded asynchronous execution.  This means that
       running a WSGI app with Tornado's `WSGIContainer` is *less scalable*
       than running the same app in a multi-threaded WSGI server like
       ``gunicorn`` or ``uwsgi``.  Use `WSGIContainer` only when there are
       benefits to combining Tornado and WSGI in the same process that
       outweigh the reduced scalability.

    Wrap a WSGI function in a `WSGIContainer` and pass it to `.HTTPServer` to
    run it. For example::

        def simple_app(environ, start_response):
            status = "200 OK"
            response_headers = [("Content-type", "text/plain")]
            start_response(status, response_headers)
            return ["Hello world!\n"]

        container = tornado.wsgi.WSGIContainer(simple_app)
        http_server = tornado.httpserver.HTTPServer(container)
        http_server.listen(8888)
        tornado.ioloop.IOLoop.current().start()

    This class is intended to let other frameworks (Django, web.py, etc)
    run on the Tornado HTTP server and I/O loop.

    The `tornado.web.FallbackHandler` class is often useful for mixing
    Tornado and WSGI apps in the same server.  See
    https://github.com/bdarnell/django-tornado-demo for a complete example.
    cC�s
||_dS(N(twsgi_application(RR`((s2/usr/lib64/python2.7/site-packages/tornado/wsgi.pyR$sc
�s�i�g�d��fd�}|jtj|�|�}z �j|�dj��}Wdt|d�r{|j�nX�s�td��n�dj	dd�\}}t
|�}�d}td	�|D��}tj
|�}|d
krAd|kr"|jdtt|��f�nd
|krA|jd�qAnd|krj|jddtjf�ntjd||�}	tj�}
x$|D]\}}|
j||�q�W|jj|	|
d|�|jj�|j||�dS(Nc�s|�d<|�d<�jS(NtstatusR/(R6(Ratresponse_headerstexc_info(tdatatresponse(s2/usr/lib64/python2.7/site-packages/tornado/wsgi.pyRs

RDtcloses$WSGI app did not call start_responseRat iR/cs�s!|]\}}|j�VqdS(N(tlower(t.0R1R2((s2/usr/lib64/python2.7/site-packages/tornado/wsgi.pys	<genexpr>!si0scontent-lengthsContent-Lengthscontent-typesContent-Typestext/html; charset=UTF-8tservertServersTornadoServer/%ssHTTP/1.1R0(sContent-Typestext/html; charset=UTF-8(R!R`R_RtextendtjointhasattrRfR\tsplitR(tsetRtutf8R6tstrR4ttornadotversionRtResponseStartLineRVtaddRRR3R8t_log(
RR>Rtapp_responseRPtstatus_codeR*R/t
header_setR.t
header_objR^tvalue((RdRes2/usr/lib64/python2.7/site-packages/tornado/wsgi.pyRs>

"
cC�s�|jjd�}t|�dkrA|d}t|d�}n$|j}|jdkr_dnd}i|jd6d	d
6ttj|j	dd!dt��d
6|jd6|j
d6|d6t|�d6|jd6d"d6|jd6ttj|j��d6tjd6td6td6td6}d|jkrD|jjd�|d<nd|jkrl|jjd�|d<nx=|jj�D],\}}||d|jdd �j�<q|W|S(#sOConverts a `tornado.httputil.HTTPServerRequest` to a WSGI environment.
        t:iiithttpsi�iPRBRDRCtencodingtplusRERFRMROtSERVER_PORTtSERVER_PROTOCOLswsgi.versionswsgi.url_schemes
wsgi.inputswsgi.errorsswsgi.multithreadswsgi.multiprocesss
wsgi.run_oncesContent-TypeRHsContent-LengthRIRJRLRKN(ii(RQRoR4R(R;RRRturl_unescapetpathR!RtqueryR:RrRtRRqRPtsyststderrR7R/tpoptitemsRXtupper(R>thostportRQtportRR^R|((s2/usr/lib64/python2.7/site-packages/tornado/wsgi.pyR3s<
	
	






$cC�s�|dkrtj}n!|dkr0tj}n	tj}d|j�}|jd|jd|jd}|d|||�dS(Ni�i�g@�@Rgs (t)s%d %s %.2fms(Rtinfotwarningterrortrequest_timeRR]R:(RRyR>t
log_methodR�tsummary((s2/usr/lib64/python2.7/site-packages/tornado/wsgi.pyRwXs	#(RRRR$RtstaticmethodRRw(((s2/usr/lib64/python2.7/site-packages/tornado/wsgi.pyR_�s
!		(%(*Rt
__future__RRRRR�tioRRsttornado.concurrentRRRttornado.logRR	ttornado.escapeR
ttornado.utilRturllib.parsetparseRStImportErrorturllibRrRRR=RR-t
set_resultR!tHTTPConnectionRtobjectR9RR_RZtHTTPRequest(((s2/usr/lib64/python2.7/site-packages/tornado/wsgi.pyt<module>s8"
			
	
5	N

Zerion Mini Shell 1.0