403Webshell
Server IP : 54.37.205.81  /  Your IP : 216.73.216.76
Web Server : nginx/1.22.1
System : Linux vps-249481fa 6.1.0-50-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.176-1 (2026-07-02) x86_64
User : debian ( 1000)
PHP Version : 8.2.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/tornado/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/tornado/__pycache__/httpserver.cpython-311.pyc
�

��b�>��`�dZddlZddlZddlmZddlmZmZddlm	Z	ddlm
Z
ddlmZddlm
Z
dd	lmZddlZdd
lmZmZmZmZmZmZmZmZmZejrddlmZGd�d
e
ee	j��ZGd�de	j��ZGd�de ��Z!Gd�de	j��Z"e	j#Z$dS)a�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.
�N)�
native_str)�HTTP1ServerConnection�HTTP1ConnectionParameters)�httputil)�iostream)�netutil)�	TCPServer)�Configurable)	�Union�Any�Dict�Callable�List�Type�Tuple�Optional�	Awaitable)�Setc��eZdZdZdededdfd�Z												d deeje	ej
gdffd	ed
edeee
eefejfdeed
edeedeedeedeedeedeedeeeddfd�Zedeefd���Zedeefd���Zd!d�Zdejdeddfd�Zdedej dej!fd�Z"deddfd�Z#dS)"�
HTTPServera�A 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``.

    By default, when parsing the ``X-Forwarded-For`` header, Tornado will
    select the last (i.e., the closest) address on the list of hosts as the
    remote host IP address.  To select the next server in the chain, a list of
    trusted downstream hosts may be passed as the ``trusted_downstream``
    argument.  These hosts will be skipped when parsing the ``X-Forwarded-For``
    header.

    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(application, 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`: single-process::

            async def main():
                server = HTTPServer()
                server.listen(8888)
                await asyncio.Event.wait()

            asyncio.run(main())

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

       While this example does not create multiple processes on its own, when
       the ``reuse_port=True`` argument is passed to ``listen()`` you can run
       the program multiple times to create a multi-process service.

    2. `~tornado.tcpserver.TCPServer.add_sockets`: multi-process::

            sockets = bind_sockets(8888)
            tornado.process.fork_processes(0)
            async def post_fork_main():
                server = HTTPServer()
                server.add_sockets(sockets)
                await asyncio.Event().wait()
            asyncio.run(post_fork_main())

       The ``add_sockets`` interface is more complicated, but it can be used with
       `tornado.process.fork_processes` to run a multi-process service with all
       worker processes forked from a single parent.  ``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`.

       Note that when using this pattern, nothing that touches the event loop
       can be run before ``fork_processes``.

    3. `~tornado.tcpserver.TCPServer.bind`/`~tornado.tcpserver.TCPServer.start`:
       simple **deprecated** multi-process::

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

       This pattern is deprecated because it requires interfaces in the
       `asyncio` module that have been deprecated since Python 3.10. Support for
       creating multiple processes in the ``start`` method will be removed in a
       future version of Tornado.

    .. 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`.

    .. versionchanged:: 4.5
       Added the ``trusted_downstream`` argument.

    .. versionchanged:: 5.0
       The ``io_loop`` argument has been removed.
    �args�kwargs�returnNc��dS�N�)�selfrrs   �4/usr/lib/python3/dist-packages/tornado/httpserver.py�__init__zHTTPServer.__init__�s	��	
��F�request_callback�
no_keep_alive�xheaders�ssl_options�protocol�decompress_request�
chunk_size�max_header_size�idle_connection_timeout�body_timeout�
max_body_size�max_buffer_size�trusted_downstreamc	���||_||_||_t||||	pd||
|���|_tj||||���t��|_|
|_	dS)Ni)�
decompressr'r(�header_timeoutr+r*r")r$r,�read_chunk_size)
r!r#r%r�conn_paramsr	r�set�_connectionsr-)rr!r"r#r$r%r&r'r(r)r*r+r,r-s              r�
initializezHTTPServer.initialize�s���.!1��� ��
� ��
�4�)�!�+�2�:�d�'�%�'�
�
�
���	���#�+�&�		
�	
�	
�	
� �E�E���"4����r c��tSr�r��clss r�configurable_basezHTTPServer.configurable_base�����r c��tSrr7r8s r�configurable_defaultzHTTPServer.configurable_default�r;r c��K�|jrDtt|j����}|����d{V��|j�BdSdS)a&Close all open connections and asynchronously wait for them to finish.

        This method is used in combination with `~.TCPServer.stop` to
        support clean shutdowns (especially for unittests). Typical
        usage would call ``stop()`` first to stop accepting new
        connections, then ``await close_all_connections()`` to wait for
        existing connections to finish.

        This method does not currently close open websocket connections.

        Note that this method is a coroutine and must be called with ``await``.

        N)r4�next�iter�close)r�conns  r�close_all_connectionsz HTTPServer.close_all_connections�sl������	���T�.�/�/�0�0�D��*�*�,�,����������	�	�	�	�	r �stream�addressc���t|||j|j��}t||j|��}|j�|��|�|��dSr)�_HTTPRequestContextr%r-rr2r4�add�
start_serving)rrDrE�contextrBs     r�
handle_streamzHTTPServer.handle_stream�sf��%��G�T�]�D�,C�
�
��%�V�T�-=�w�G�G������d�#�#�#����4� � � � � r �server_conn�request_connc���t|jtj��r|j�||��}nt|j|��}|jrt||��}|Sr)�
isinstancer!r�HTTPServerConnectionDelegate�
start_request�_CallableAdapterr#�
_ProxyAdapter)rrLrM�delegates    rrQzHTTPServer.start_request�sg���d�+�X�-R�S�S�	M��,�:�:�;��U�U�H�H�'��(=�|�L�L�H��=�	=�$�X�|�<�<�H��r c�j�|j�tjt|����dSr)r4�remove�typing�castr)rrLs  r�on_closezHTTPServer.on_closes,���� � ���-B�K�!P�!P�Q�Q�Q�Q�Qr )FFNNFNNNNNNN�rN)$�__name__�
__module__�__qualname__�__doc__rrrrrPr�HTTPServerRequest�boolrr
�str�ssl�
SSLContext�int�floatrr5�classmethodrr
r:r=rCr�IOStreamrrK�object�HTTPConnection�HTTPMessageDelegaterQrYrr rrr.si������k�k�Z
�c�
�S�
�T�
�
�
�
�$��GK�"&�#(�$(�)-�37�(,�'+�)-�26�#*5�*5���1��h�0�1�4�7�8�
:�
�*5��
*5��*5��e�D��c��N�C�N�$B�C�D�*5��3�-�*5�!�*5��S�M�*5�"�#��*5�"*�%��*5��u�o�*5� ��}�*5� "�#��!*5�"%�T�#�Y�/�#*5�$
�%*5�*5�*5�*5�X��$�|�"4�����[����T�,�%7�����[������&!�H�$5�!��!�$�!�!�!�!��!��19�1H��	�	%�����R�F�R�t�R�R�R�R�R�Rr rc���eZdZdeejgdfdejddfd�Zdeej	ej
fdejdee
dfd�Zd	edee
dfd
�Zd
d�Zd
d�ZdS)rRr!NrMrc�L�||_||_d|_d|_g|_dSr)�
connectionr!�requestrT�_chunks)rr!rMs   rrz_CallableAdapter.__init__s,��
'��� 0��������
�����r �
start_line�headersc��tj|jtjtj|��|���|_dS)N)rmrprq)rr_rmrWrX�RequestStartLinern�rrprqs   r�headers_receivedz!_CallableAdapter.headers_receiveds>��
 �1����{�8�#<�j�I�I��
�
�
���
�tr �chunkc�:�|j�|��dSr)ro�append�rrvs  r�
data_receivedz_CallableAdapter.data_receiveds������E�"�"�"��tr c���|j�J�d�|j��|j_|j���|�|j��dS)Nr )rn�joinro�body�_parse_bodyr!�rs r�finishz_CallableAdapter.finish sX���|�'�'�'��H�H�T�\�2�2������ � �"�"�"����d�l�+�+�+�+�+r c�
�|`dSr)rors r�on_connection_closez$_CallableAdapter.on_connection_close&s���L�L�Lr rZ)r[r\r]rrr_rirrrs�ResponseStartLine�HTTPHeadersrrru�bytesrzr�r�rr rrRrRs�������	�"�H�$>�#?��#E�F�	��-�	�
�		�	�	�	�
��(�3�X�5O�O�P�
��%�
�
�)�D�/�	"�	
�
�
�
��5��X�i��o�-F�����,�,�,�,������r rRc��eZdZ	ddejdedeedeeeddf
d�Z	defd�Z
d	ejddfd
�Z
d
d�ZdS)rGNrDrEr%r-rc��||_|j�|jj|_nd|_|jtjtjfvr|�|d|_nd|_|r||_n)t|tj
��rd|_nd|_|j|_|j|_t|pg��|_dS)Nrz0.0.0.0�https�http)rE�socket�family�address_family�AF_INET�AF_INET6�	remote_ipr%rOr�SSLIOStream�_orig_remote_ip�_orig_protocolr3r-)rrDrEr%r-s     rrz_HTTPRequestContext.__init__+s�������=�$�"(�-�"6�D���"&�D��
��F�N�F�O�#D�D�D��#�$�Q�Z�D�N�N�'�D�N��	#�$�D�M�M�
��� 4�
5�
5�	#�#�D�M�M�"�D�M�#�~���"�m���"%�&8�&>�B�"?�"?����r c���|jtjtjfvr|jSt|jt��rt|j��St|j��Sr)
r�r�r�r�r�rOrEr�rrars r�__str__z_HTTPRequestContext.__str__MsW����6�>�6�?�"C�C�C��>�!�
���e�
,�
,�	%��d�l�+�+�+��t�|�$�$�$r rqc���|�d|j��}d�t|�d����D��D]
}||jvrn�|�d|��}tj|��r||_|�d|�d|j����}|r-|�d��d���}|dvr	||_d	Sd	S)
z2Rewrite the ``remote_ip`` and ``protocol`` fields.zX-Forwarded-Forc3�>K�|]}|���V��dSr)�strip)�.0�cands  r�	<genexpr>z6_HTTPRequestContext._apply_xheaders.<locals>.<genexpr>]s*����D�D�D�4�:�:�<�<�D�D�D�D�D�Dr �,z	X-Real-IpzX-SchemezX-Forwarded-Proto���)r�r�N)	�getr��reversed�splitr-r�is_valid_ipr%r�)rrq�ip�proto_headers    r�_apply_xheadersz#_HTTPRequestContext._apply_xheadersXs���[�[�*�D�N�
;�
;��D�D�H�R�X�X�c�]�]�,C�,C�D�D�D�	�	�B���0�0�0���1�
�[�[��b�
)�
)����r�"�"�	 ��D�N��{�{�����$7���G�G�
�
���	?�(�-�-�c�2�2�2�6�<�<�>�>�L��,�,�,�(�D�M�M�M�-�,r c�6�|j|_|j|_dS)z�Undo changes from `_apply_xheaders`.

        Xheaders are per-request so they should not leak to the next
        request on the same connection.
        N)r�r�r�r%rs r�_unapply_xheadersz%_HTTPRequestContext._unapply_xheadersns���-����+��
�
�
r rrZ)r[r\r]rrgrrrarrr�rr�r�r�rr rrGrG*s�������37� @� @��!� @�� @��3�-�	 @�
%�T�#�Y�/� @�
�
 @� @� @� @�D	%��	%�	%�	%�	%�)�x�';�)��)�)�)�)�,,�,�,�,�,�,r rGc���eZdZdejdejddfd�Zdeejej	fdej
deedfd�Z
d	edeedfd
�Zdd�Zdd�Zdd
�ZdS)rSrTrMrNc�"�||_||_dSr)rmrT)rrTrMs   rrz_ProxyAdapter.__init__ys��
'��� ��
�
�
r rprqc�v�|jj�|��|j�||��Sr)rmrJr�rTrurts   rruz_ProxyAdapter.headers_received�s5��	
���/�/��8�8�8��}�-�-�j�'�B�B�Br rvc�6�|j�|��Sr)rTrzrys  rrzz_ProxyAdapter.data_received�s���}�*�*�5�1�1�1r c�`�|j���|���dSr)rTr��_cleanuprs rr�z_ProxyAdapter.finish�s'���
�������
�
�����r c�`�|j���|���dSr)rTr�r�rs rr�z!_ProxyAdapter.on_connection_close�s'���
�)�)�+�+�+��
�
�����r c�B�|jj���dSr)rmrJr�rs rr�z_ProxyAdapter._cleanup�s�����1�1�3�3�3�3�3r rZ)r[r\r]rrjrirrrsr�r�rrrur�rzr�r�r�rr rrSrSxs������!��.�!��-�!�
�	!�!�!�!�C��(�3�X�5O�O�P�C��%�C�
�)�D�/�	"�	C�C�C�C�2�5�2�X�i��o�-F�2�2�2�2���������4�4�4�4�4�4r rS)%r^r�rb�tornado.escaper�tornado.http1connectionrr�tornadorrr�tornado.tcpserverr	�tornado.utilr
rWrrr
rrrrrr�
TYPE_CHECKINGrrPrrjrRrhrGrSr_�HTTPRequestrr r�<module>r�s��� 
�
��
�
�
�
�
�
�
�%�%�%�%�%�%�T�T�T�T�T�T�T�T�������������������'�'�'�'�'�'�%�%�%�%�%�%�
�
�
�
�U�U�U�U�U�U�U�U�U�U�U�U�U�U�U�U�U�U�U�U�U�U�	���������SR�SR�SR�SR�SR��L�(�*O�SR�SR�SR�l#�#�#�#�#�x�3�#�#�#�LK,�K,�K,�K,�K,�&�K,�K,�K,�\4�4�4�4�4�H�0�4�4�4�D�(���r 

Youez - 2016 - github.com/yon3zu
LinuXploit