%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/httpserver.pyc

�
��L]c@�sdZddlmZmZmZmZddlZddlmZddl	m
Z
mZddlm
Z
ddlmZddlmZdd	lmZdd
lmZddlmZdeeejfd
��YZdefd��YZdejfd��YZejZdS(s�A non-blocking, single-threaded HTTP server.

Typical applications have little direct interaction with the `HTTPServer`
class except to start a server at the beginning of the process
(and even that is often done indirectly via `tornado.web.Application.listen`).

.. versionchanged:: 4.0

   The ``HTTPRequest`` class that used to live in this module has been moved
   to `tornado.httputil.HTTPServerRequest`.  The old name remains as an alias.
i(tabsolute_importtdivisiontprint_functiontwith_statementN(t
native_str(tHTTP1ServerConnectiontHTTP1ConnectionParameters(tgen(thttputil(tiostream(tnetutil(t	TCPServer(tConfigurablet
HTTPServerc
B�s�eZdZd�Zed	ed	d	ed	d	d	d	d	d	d�Zed��Zed��Z	e
jd��Zd�Z
d�Zd�ZRS(
sqA non-blocking, single-threaded HTTP server.

    A server is defined by a subclass of `.HTTPServerConnectionDelegate`,
    or, for backwards compatibility, a callback that takes an
    `.HTTPServerRequest` as an argument. The delegate is usually a
    `tornado.web.Application`.

    `HTTPServer` supports keep-alive connections by default
    (automatically for HTTP/1.1, or for HTTP/1.0 when the client
    requests ``Connection: keep-alive``).

    If ``xheaders`` is ``True``, we support the
    ``X-Real-Ip``/``X-Forwarded-For`` and
    ``X-Scheme``/``X-Forwarded-Proto`` headers, which override the
    remote IP and URI scheme/protocol for all requests.  These headers
    are useful when running Tornado behind a reverse proxy or load
    balancer.  The ``protocol`` argument can also be set to ``https``
    if Tornado is run behind an SSL-decoding proxy that does not set one of
    the supported ``xheaders``.

    To make this server serve SSL traffic, send the ``ssl_options`` keyword
    argument with an `ssl.SSLContext` object. For compatibility with older
    versions of Python ``ssl_options`` may also be a dictionary of keyword
    arguments for the `ssl.wrap_socket` method.::

       ssl_ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
       ssl_ctx.load_cert_chain(os.path.join(data_dir, "mydomain.crt"),
                               os.path.join(data_dir, "mydomain.key"))
       HTTPServer(applicaton, ssl_options=ssl_ctx)

    `HTTPServer` initialization follows one of three patterns (the
    initialization methods are defined on `tornado.tcpserver.TCPServer`):

    1. `~tornado.tcpserver.TCPServer.listen`: simple single-process::

            server = HTTPServer(app)
            server.listen(8888)
            IOLoop.current().start()

       In many cases, `tornado.web.Application.listen` can be used to avoid
       the need to explicitly create the `HTTPServer`.

    2. `~tornado.tcpserver.TCPServer.bind`/`~tornado.tcpserver.TCPServer.start`:
       simple multi-process::

            server = HTTPServer(app)
            server.bind(8888)
            server.start(0)  # Forks multiple sub-processes
            IOLoop.current().start()

       When using this interface, an `.IOLoop` must *not* be passed
       to the `HTTPServer` constructor.  `~.TCPServer.start` will always start
       the server on the default singleton `.IOLoop`.

    3. `~tornado.tcpserver.TCPServer.add_sockets`: advanced multi-process::

            sockets = tornado.netutil.bind_sockets(8888)
            tornado.process.fork_processes(0)
            server = HTTPServer(app)
            server.add_sockets(sockets)
            IOLoop.current().start()

       The `~.TCPServer.add_sockets` interface is more complicated,
       but it can be used with `tornado.process.fork_processes` to
       give you more flexibility in when the fork happens.
       `~.TCPServer.add_sockets` can also be used in single-process
       servers if you want to create your listening sockets in some
       way other than `tornado.netutil.bind_sockets`.

    .. versionchanged:: 4.0
       Added ``decompress_request``, ``chunk_size``, ``max_header_size``,
       ``idle_connection_timeout``, ``body_timeout``, ``max_body_size``
       arguments.  Added support for `.HTTPServerConnectionDelegate`
       instances as ``request_callback``.

    .. versionchanged:: 4.1
       `.HTTPServerConnectionDelegate.start_request` is now called with
       two arguments ``(server_conn, request_conn)`` (in accordance with the
       documentation) instead of one ``(request_conn)``.

    .. versionchanged:: 4.2
       `HTTPServer` is now a subclass of `tornado.util.Configurable`.
    cO�sdS(N((tselftargstkwargs((s8/usr/lib64/python2.7/site-packages/tornado/httpserver.pyt__init__scC�s�||_||_||_||_td|d|d|	d|
pEdd|d|�|_tj|d|d	|d
|
d|�t�|_	dS(Nt
decompresst
chunk_sizetmax_header_sizetheader_timeoutit
max_body_sizetbody_timeouttio_looptssl_optionstmax_buffer_sizetread_chunk_size(
trequest_callbackt
no_keep_alivetxheaderstprotocolRtconn_paramsRRtsett_connections(RRRRRRRtdecompress_requestRRtidle_connection_timeoutRRR((s8/usr/lib64/python2.7/site-packages/tornado/httpserver.pyt
initialize�s				cC�stS(N(R
(tcls((s8/usr/lib64/python2.7/site-packages/tornado/httpserver.pytconfigurable_base�scC�stS(N(R
(R&((s8/usr/lib64/python2.7/site-packages/tornado/httpserver.pytconfigurable_default�scc�s4x-|jr/tt|j��}|j�VqWdS(N(R"tnexttitertclose(Rtconn((s8/usr/lib64/python2.7/site-packages/tornado/httpserver.pytclose_all_connections�scC�sKt|||j�}t||j|�}|jj|�|j|�dS(N(t_HTTPRequestContextRRR R"taddt
start_serving(RtstreamtaddresstcontextR,((s8/usr/lib64/python2.7/site-packages/tornado/httpserver.pyt
handle_stream�s	cC�st|||�S(N(t_ServerRequestAdapter(Rtserver_conntrequest_conn((s8/usr/lib64/python2.7/site-packages/tornado/httpserver.pyt
start_request�scC�s|jj|�dS(N(R"tremove(RR6((s8/usr/lib64/python2.7/site-packages/tornado/httpserver.pyton_close�sN(t__name__t
__module__t__doc__RtFalsetNoneR%tclassmethodR'R(Rt	coroutineR-R4R8R:(((s8/usr/lib64/python2.7/site-packages/tornado/httpserver.pyR
*sT				R.cB�s,eZd�Zd�Zd�Zd�ZRS(cC�s�||_||_|jdk	r3|jj|_n	d|_|jtjtjfkrs|dk	rs|d|_n	d|_|r�||_n't	|t
j�r�d|_n	d|_|j|_|j|_
dS(Nis0.0.0.0thttpsthttp(R2RtsocketR?tfamilytaddress_familytAF_INETtAF_INET6t	remote_ipt
isinstanceR	tSSLIOStreamt_orig_remote_ipt_orig_protocol(RR1R2R((s8/usr/lib64/python2.7/site-packages/tornado/httpserver.pyR�s 					cC�sR|jtjtjfkr"|jSt|jt�rAt|j�St	|j�SdS(N(
RFRDRGRHRIRJR2tbytesRtstr(R((s8/usr/lib64/python2.7/site-packages/tornado/httpserver.pyt__str__�s

cC�s�|jd|j�}|jd�dj�}|jd|�}tj|�r[||_n|jd|jd|j��}|d
kr�||_nd	S(s2Rewrite the ``remote_ip`` and ``protocol`` fields.sX-Forwarded-Fort,i����s	X-Real-IpsX-SchemesX-Forwarded-ProtoRCRBN(shttpshttps(tgetRItsplittstripR
tis_valid_ipR(Rtheaderstiptproto_header((s8/usr/lib64/python2.7/site-packages/tornado/httpserver.pyt_apply_xheaders�scC�s|j|_|j|_dS(s�Undo changes from `_apply_xheaders`.

        Xheaders are per-request so they should not leak to the next
        request on the same connection.
        N(RLRIRMR(R((s8/usr/lib64/python2.7/site-packages/tornado/httpserver.pyt_unapply_xheaders�s(R;R<RRPRYRZ(((s8/usr/lib64/python2.7/site-packages/tornado/httpserver.pyR.�s			R5cB�sDeZdZd�Zd�Zd�Zd�Zd�Zd�ZRS(s]Adapts the `HTTPMessageDelegate` interface to the interface expected
    by our clients.
    cC�sj||_||_d|_t|jtj�rT|jj||�|_	d|_
nd|_	g|_
dS(N(tservert
connectionR?trequestRJRRtHTTPServerConnectionDelegateR8tdelegatet_chunks(RR[R6R7((s8/usr/lib64/python2.7/site-packages/tornado/httpserver.pyR�s						cC�so|jjr"|jjj|�n|jdkrXtjd|jd|d|�|_	n|jj
||�SdS(NR\t
start_lineRV(R[RR\R3RYR_R?RtHTTPServerRequestR]theaders_received(RRaRV((s8/usr/lib64/python2.7/site-packages/tornado/httpserver.pyRcs	cC�s6|jdkr"|jj|�n|jj|�SdS(N(R_R?R`tappendt
data_received(Rtchunk((s8/usr/lib64/python2.7/site-packages/tornado/httpserver.pyRescC�se|jdkrJdj|j�|j_|jj�|jj|j�n
|jj	�|j
�dS(Nt(R_R?tjoinR`R]tbodyt_parse_bodyR[Rtfinisht_cleanup(R((s8/usr/lib64/python2.7/site-packages/tornado/httpserver.pyRks

cC�s6|jdkrd|_n
|jj�|j�dS(N(R_R?R`ton_connection_closeRl(R((s8/usr/lib64/python2.7/site-packages/tornado/httpserver.pyRm$s
cC�s#|jjr|jjj�ndS(N(R[RR\R3RZ(R((s8/usr/lib64/python2.7/site-packages/tornado/httpserver.pyRl+s(	R;R<R=RRcReRkRmRl(((s8/usr/lib64/python2.7/site-packages/tornado/httpserver.pyR5�s	
	
				(R=t
__future__RRRRRDttornado.escapeRttornado.http1connectionRRttornadoRRR	R
ttornado.tcpserverRttornado.utilRR^R
tobjectR.tHTTPMessageDelegateR5RbtHTTPRequest(((s8/usr/lib64/python2.7/site-packages/tornado/httpserver.pyt<module>s"	�?6

Zerion Mini Shell 1.0