Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/future/backports/http/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/future/backports/http/__pycache__/server.cpython-311.pyc

�

�܋fӱ���dZddlmZmZmZmZddlmZddlTdZ	ddgZ
ddlmZdd	l
mZdd
lmZddlmZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZd
ZdZ d�Z!Gd�dej"��Z#Gd�dej$��Z%Gd�de%��Z&d�Z'da(d�Z)d�Z*Gd�de&��Z+e%e#ddfd�Z,e-dkr�ej.��Z/e/�0ddd� ��e/�0d!d"de1d#d$�%��e/�2��Z3e3j4re,e+e3j5�&��dSe,e&e3j5�&��dSdS)'aQHTTP server classes.

From Python 3.3

Note: BaseHTTPRequestHandler doesn't implement any HTTP request; see
SimpleHTTPRequestHandler for simple implementations of GET, HEAD and POST,
and CGIHTTPRequestHandler for CGI scripts.

It does, however, optionally implement HTTP/1.1 persistent connections,
as of version 0.3.

Notes on CGIHTTPRequestHandler
------------------------------

This class implements GET and POST requests to cgi-bin scripts.

If the os.fork() function is not present (e.g. on Windows),
subprocess.Popen() is used as a fallback, with slightly altered semantics.

In all cases, the implementation is intentionally naive -- all
requests are executed synchronously.

SECURITY WARNING: DON'T USE THIS CODE UNLESS YOU ARE INSIDE A FIREWALL
-- it may execute arbitrary Python code or external programs.

Note that status code 200 is sent prior to execution of a CGI script, so
scripts cannot send other status codes such as 302 (redirect).

XXX To do:

- log requests even later (to capture byte count)
- log user-agent header and other interesting goodies
- send error log to separate file
�)�absolute_import�division�print_function�unicode_literals)�utils)�*z0.6�
HTTPServer�BaseHTTPRequestHandler��html)�client)�parse)�socketserverNa�<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
        <title>Error response</title>
    </head>
    <body>
        <h1>Error response</h1>
        <p>Error code: %(code)d</p>
        <p>Message: %(message)s.</p>
        <p>Error code explanation: %(code)s - %(explain)s.</p>
    </body>
</html>
ztext/html;charset=utf-8c�t�|jdd���dd���dd��S)N�&z&amp;�<z&lt;�>z&gt;)�replacers �m/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib/python3.11/site-packages/future/backports/http/server.py�_quote_htmlr�s6���4�<��W�%�%�-�-�c�6�:�:�B�B�3��O�O�O�c��eZdZdZd�ZdS)r	�c���tj�|��|j���dd�\}}tj|��|_||_dS)z.Override server_bind to store the server name.N�)r�	TCPServer�server_bind�socket�getsockname�getfqdn�server_name�server_port)�self�host�ports   rrzHTTPServer.server_bind�sY����*�*�4�0�0�0��[�,�,�.�.�r��r�2�
��d�!�>�$�/�/�������rN)�__name__�
__module__�__qualname__�allow_reuse_addressr�rrr	r	�s)�������� � � � � rc���eZdZdZdej���dzZdezZ	e
ZeZ
dZd�Zd�Zd�Zd	�Zdkd�Zdkd�Zdkd
�Zd�Zd�Zd�Zdld�Zd�Zd�Zd�Zdkd�Zd�Zgd�Zgd�Z d�Z!dZ"e#j$Z%idd�dd�d d!�d"d#�d$d%�d&d'�d(d)�d*d+�d,d-�d.d/�d0d1�d2d3�d4d5�d6d7�d8d9�d:d;�d<d=�id>d?�d@dA�dBdC�dDdE�dFdG�dHdI�dJdK�dLdM�dNdO�dPdQ�dRdS�dTdU�dVdW�dXdY�dZd[�d\d]�d^d_��d`dadbdcdddedfdgdhdidj�
�Z&d
S)mr
a�HTTP request handler base class.

    The following explanation of HTTP serves to guide you through the
    code as well as to expose any misunderstandings I may have about
    HTTP (so you don't need to read the code to figure out I'm wrong
    :-).

    HTTP (HyperText Transfer Protocol) is an extensible protocol on
    top of a reliable stream transport (e.g. TCP/IP).  The protocol
    recognizes three parts to a request:

    1. One line identifying the request type and path
    2. An optional set of RFC-822-style headers
    3. An optional data part

    The headers and data are separated by a blank line.

    The first line of the request has the form

    <command> <path> <version>

    where <command> is a (case-sensitive) keyword such as GET or POST,
    <path> is a string containing path information for the request,
    and <version> should be the string "HTTP/1.0" or "HTTP/1.1".
    <path> is encoded using the URL encoding scheme (using %xx to signify
    the ASCII character with hex code xx).

    The specification specifies that lines are separated by CRLF but
    for compatibility with the widest range of clients recommends
    servers also handle LF.  Similarly, whitespace in the request line
    is treated sensibly (allowing multiple spaces between components
    and allowing trailing whitespace).

    Similarly, for output, lines ought to be separated by CRLF pairs
    but most clients grok LF characters just fine.

    If the first line of the request has the form

    <command> <path>

    (i.e. <version> is left out) then this is assumed to be an HTTP
    0.9 request; this form has no optional headers and data part and
    the reply consists of just the data.

    The reply form of the HTTP 1.x protocol again has three parts:

    1. One line giving the response code
    2. An optional set of RFC-822-style headers
    3. The data

    Again, the headers and data are separated by a blank line.

    The response code line has the form

    <version> <responsecode> <responsestring>

    where <version> is the protocol version ("HTTP/1.0" or "HTTP/1.1"),
    <responsecode> is a 3-digit response code indicating success or
    failure of the request, and <responsestring> is an optional
    human-readable string explaining what the response code means.

    This server parses the request and the headers, and then calls a
    function specific to the request type (<command>).  Specifically,
    a request SPAM will be handled by a method do_SPAM().  If no
    such method exists the server sends an error response to the
    client.  If it exists, it is called with no arguments:

    do_SPAM()

    Note that the request name is case sensitive (i.e. SPAM and spam
    are different requests).

    The various request details are stored in instance variables:

    - client_address is the client IP address in the form (host,
    port);

    - command, path and version are the broken-down request line;

    - headers is an instance of email.message.Message (or a derived
    class) containing the header information;

    - rfile is a file object open for reading positioned at the
    start of the optional input data part;

    - wfile is a file object open for writing.

    IT IS IMPORTANT TO ADHERE TO THE PROTOCOL FOR WRITING!

    The first thing to be written must be the response line.  Then
    follow 0 or more header lines, then a blank line, and then the
    actual data (if any).  The meaning of the header lines depends on
    the command executed by the server; in most cases, when data is
    returned, there should be at least one header line of the form

    Content-type: <type>/<subtype>

    where <type> and <subtype> should be registered MIME types,
    e.g. "text/html" or "text/plain".

    zPython/rz	BaseHTTP/�HTTP/0.9c�,�d|_|jx|_}d|_t	|jd��}|�d��}||_|���}t|��dk�r|\}}}|dd�dkr|�
dd	|z��d
S	|�dd��d}|�d��}t|��d
krt�t|d��t|d��f}n1#ttf$r|�
dd	|z��Yd
SwxYw|dkr|jdkrd|_|dkr|�
dd|z��d
Sn`t|��d
kr.|\}}d|_|dkr|�
dd|z��d
Sn|sd
S|�
dd|z��d
S|||c|_|_|_	t!j|j|j���|_n,#t j$r|�
dd��Yd
SwxYw|j�dd��}|���dkrd|_n*|���dkr|jdkrd|_|j�dd��}	|	���dkr,|jdkr!|jdkr|���sd
SdS) a'Parse a request (internal).

        The request should be stored in self.raw_requestline; the results
        are in self.command, self.path, self.request_version and
        self.headers.

        Return True for success, False for failure; on failure, an
        error is sent back.

        Nrz
iso-8859-1�
��zHTTP/�zBad request version (%r)F�/�.rr)rrzHTTP/1.1)rr�zInvalid HTTP Version (%s)�GETzBad HTTP/0.9 request type (%r)zBad request syntax (%r))�_classz
Line too long�
Connection��close�
keep-alive�Expectz100-continueT)�command�default_request_version�request_version�close_connection�str�raw_requestline�rstrip�requestline�split�len�
send_error�
ValueError�int�
IndexError�protocol_version�path�http_client�
parse_headers�rfile�MessageClass�headers�LineTooLong�get�lower�handle_expect_100)
r#�versionrC�wordsr<rK�base_version_number�version_number�conntype�expects
          r�
parse_requestz$BaseHTTPRequestHandler.parse_requests������)-�)E�E���w� !����$�.��=�=��!�(�(��0�0��&����!�!�#�#���u�:�:��?�?�%*�"�G�T�7��r��r�{�g�%�%�����%?�'�%I�J�J�J��u�
�&-�m�m�C��&;�&;�A�&>�#�!4�!:�!:�3�!?�!?���~�&�&�!�+�+�$�$�!$�^�A�%6�!7�!7��^�A�=N�9O�9O�!O�����
�+�
�
�
�����%?�'�%I�J�J�J��u�u�
������'�'�D�,A�Z�,O�,O�()��%���'�'�����5�8K�K�M�M�M��u�(���Z�Z�1�_�_�!�M�G�T�$%�D�!��%������� @�7� J�L�L�L��u� ��	��5��O�O�C�!:�[�!H�I�I�I��5�8?��w�5���d�i��!5�	�&�4�T�Z�<@�<M�O�O�O�D�L�L���&�	�	�	��O�O�C��1�1�1��5�5�	�����<�#�#�L�"�5�5���>�>���w�&�&�$%�D�!�!��n�n���,�.�.��#�z�1�1�$%�D�!���!�!�(�B�/�/���L�L�N�N�n�,�,��%��3�3��$�
�2�2��)�)�+�+�
��u��ts%�&A5D�*E
�	E
�>%H$�$%I
�I
c�X�|�d��|���dS)a7Decide what to do with an "Expect: 100-continue" header.

        If the client is expecting a 100 Continue response, we must
        respond with either a 100 Continue or a final response before
        waiting for the request body. The default is to always respond
        with a 100 Continue. You can behave differently (for example,
        reject unauthorized requests) by overriding this method.

        This method should either return True (possibly after sending
        a 100 Continue response) or send an error response and return
        False.

        �dT)�send_response_only�
flush_headers�r#s rrTz(BaseHTTPRequestHandler.handle_expect_100]s/��	
����$�$�$��������trc�h�	|j�d��|_t|j��dkr,d|_d|_d|_|�d��dS|js	d|_dS|�	��sdSd|jz}t||��s |�dd	|jz��dSt||��}|��|j�
��dS#tj$r(}|�d
|��d|_Yd}~dSd}~wwxYw)z�Handle a single HTTP request.

        You normally don't need to override this method; see the class
        __doc__ string for information on how to handle specific HTTP
        commands such as GET and POST.

        iir8�Nr�do_�zUnsupported method (%r)zRequest timed out: %r)rN�readlinerArErCr>r<rFr?r[�hasattr�getattr�wfile�flushr�timeout�	log_error)r#�mname�method�es    r�handle_one_requestz)BaseHTTPRequestHandler.handle_one_requestosR��	�#'�:�#6�#6�u�#=�#=�D� ��4�'�(�(�5�0�0�#%�� �')��$�!�������$�$�$����'�
�()��%����%�%�'�'�
����D�L�(�E��4��'�'�
�����%>���%M�N�N�N����T�5�)�)�F��F�H�H�H��J����������~�	�	�	��N�N�2�A�6�6�6�$%�D�!��F�F�F�F�F�����		���s0�A!C:�%C:�5C:�8C:�3C:�:D1�	D,�,D1c��d|_|���|js|���|j�dSdS)z&Handle multiple requests if necessary.rN)r?ror`s r�handlezBaseHTTPRequestHandler.handle�sZ�� !������!�!�!��'�	&��#�#�%�%�%��'�	&�	&�	&�	&�	&rNc��	|j|\}}n#t$rd\}}YnwxYw|�|}|}|�d||��|j|t	|��|d�z}|�||��|�d|j��|�dd��|���|j	dkr:|d	kr6|d
vr4|j
�|�dd����dSdSdSdS)
a�Send and log an error reply.

        Arguments are the error code, and a detailed message.
        The detailed message defaults to the short entry matching the
        response code.

        This sends an error response (so it must be called before any
        output has been generated), logs the error, and finally sends
        a piece of HTML explaining the error to the user.

        )�???rsNzcode %d, message %s)�code�message�explainzContent-Typer7r9�HEAD��)���0zUTF-8r)
�	responses�KeyErrorrk�error_message_formatr�
send_response�send_header�error_content_type�end_headersr<rh�write�encode)r#rtru�shortmsg�longmsgrv�contents       rrFz!BaseHTTPRequestHandler.send_error�s>��	-� $��t� 4��H�g�g���	-�	-�	-� ,��H�g�g�g�	-�����?��G������,�d�G�<�<�<��,� �[��-A�-A�g�V�V�W�����4��)�)�)������)@�A�A�A�����w�/�/�/��������<�6�!�!�d�c�k�k�d�*�6L�6L��J���W�^�^�G�Y�?�?�@�@�@�@�@�"�!�k�k�6L�6Ls��%�%c��|�|��|�||��|�d|�����|�d|�����dS)z�Add the response header to the headers buffer and log the
        response code.

        Also send two standard headers with the server software
        version and the current date.

        �Server�DateN)�log_requestr^r�version_string�date_time_string�r#rtrus   rr~z$BaseHTTPRequestHandler.send_response�sx��	
�����������g�.�.�.�����4�#6�#6�#8�#8�9�9�9������!6�!6�!8�!8�9�9�9�9�9rc��|�||jvr|j|d}nd}|jdkrRt|d��sg|_|j�d|j||fz�dd����dSdS)	zSend the response header only.Nrr8r,�_headers_bufferz
%s %d %s
�latin-1�strict)r{r>rfr��appendrJr�r�s   rr^z)BaseHTTPRequestHandler.send_response_only�s����?��t�~�%�%��.��.�q�1�������:�-�-��4�!2�3�3�
*�')��$�� �'�'���*�D�'�:�*;�<B�F�!�8�=-�=-�
.�
.�
.�
.�
.�.�-rc�j�|jdkrKt|d��sg|_|j�|�d|�d��dd����|���dkrB|���dkr	d	|_dS|���d
krd|_dSdSdS)
z)Send a MIME header to the headers buffer.r,r�z: r.r�r��
connectionr9rr:rN)r>rfr�r�r�rSr?)r#�keyword�values   rrz"BaseHTTPRequestHandler.send_header�s�����:�-�-��4�!2�3�3�
*�')��$�� �'�'�!(���%�%�%�0�8�8��H�M�M�
O�
O�
O��=�=�?�?�l�*�*��{�{�}�}��'�'�()��%�%�%������,�.�.�()��%�%�%�	+�*�/�.rc�|�|jdkr0|j�d��|���dSdS)z,Send the blank line ending the MIME headers.r,s
N)r>r�r�r_r`s rr�z"BaseHTTPRequestHandler.end_headers�sG����:�-�-�� �'�'��0�0�0���� � � � � �.�-rc��t|d��r;|j�d�|j����g|_dSdS)Nr�r)rfrhr��joinr�r`s rr_z$BaseHTTPRequestHandler.flush_headers�sR���4�*�+�+�	&��J���S�X�X�d�&:�;�;�<�<�<�#%�D� � � �	&�	&r�-c�t�|�d|jt|��t|����dS)zNLog an accepted request.

        This is called by send_response().

        z
"%s" %s %sN)�log_messagerCr@)r#rt�sizes   rr�z"BaseHTTPRequestHandler.log_request�sC��	
�����)�3�t�9�9�c�$�i�i�	A�	A�	A�	A�	Arc�"�|j|g|�R�dS)z�Log an error.

        This is called when a request cannot be fulfilled.  By
        default it passes the message on to log_message().

        Arguments are the same as for log_message().

        XXX This should go to the separate error log.

        N)r��r#�format�argss   rrkz BaseHTTPRequestHandler.log_error�s%��	����'�$�'�'�'�'�'�'rc��tj�|����d|����d||z�d���dS)a�Log an arbitrary message.

        This is used by all other logging functions.  Override
        it if you have specific logging wishes.

        The first argument, FORMAT, is a format string for the
        message to be logged.  If the format string contains
        any % escapes requiring parameters, they should be
        specified as subsequent arguments (it's just like
        printf!).

        The client ip and current date/time are prefixed to
        every message.

        z - - [z] �
N)�sys�stderrr��address_string�log_date_time_stringr�s   rr�z"BaseHTTPRequestHandler.log_messagesb��"	�
����-�-�/�/�/�/��3�3�5�5�5�5� ��+�+�+�'�	(�	(�	(�	(�	(rc�&�|jdz|jzS)z*Return the server software version string.� )�server_version�sys_versionr`s rr�z%BaseHTTPRequestHandler.version_strings���"�S�(�4�+;�;�;rc	��|�tj��}tj|��\	}}}}}}}}	}
d|j|||j|||||fz}|S)z@Return the current date and time formatted for a message header.Nz#%s, %02d %3s %4d %02d:%02d:%02d GMT)�time�gmtime�weekdayname�	monthname)r#�	timestamp�year�month�day�hh�mm�ss�wd�y�z�ss            rr�z'BaseHTTPRequestHandler.date_time_stringsk�����	���I�15��Y�1G�1G�.��e�S�"�b�"�b�!�Q�1�� ��$��T�^�E�*�D��B��5�
���rc	��tj��}tj|��\	}}}}}}}}	}
d||j|||||fz}|S)z.Return the current time formatted for logging.z%02d/%3s/%04d %02d:%02d:%02d)r��	localtimer�)r#�nowr�r�r�r�r�r��xr�r�r�s            rr�z+BaseHTTPRequestHandler.log_date_time_string*sW���i�k�k��04��s�0C�0C�-��e�S�"�b�"�a��A�*��T�^�E�*�D�"�b�"�.>�
>���r)�Mon�Tue�Wed�Thu�Fri�Sat�Sun)
N�Jan�Feb�Mar�Apr�May�Jun�Jul�Aug�Sep�Oct�Nov�Decc��|jdS)zReturn the client address.r)�client_addressr`s rr�z%BaseHTTPRequestHandler.address_string8s���"�1�%�%r�HTTP/1.0r])�Continuez!Request received, please continue�e)zSwitching Protocolsz.Switching to new protocol; obey Upgrade headerrx)�OKz#Request fulfilled, document follows��)�CreatedzDocument created, URL follows��)�Acceptedz/Request accepted, processing continues off-line��)zNon-Authoritative InformationzRequest fulfilled from cachery)z
No Contentz"Request fulfilled, nothing follows��)z
Reset Contentz#Clear input form for further input.��)zPartial ContentzPartial content follows.i,)zMultiple Choicesz,Object has several resources -- see URI list�-)zMoved Permanentlyz(Object moved permanently -- see URI listi.)�Found�(Object moved temporarily -- see URI listi/)z	See Otherz'Object moved -- see Method and URL listrz)zNot Modifiedz)Document has not changed since given timei1)z	Use ProxyzAYou must use proxy specified in Location to access this resource.i3)zTemporary Redirectr�r1)zBad Requestz(Bad request syntax or unsupported methodi�)�Unauthorizedz*No permission -- see authorization schemesi�)zPayment Requiredz"No payment -- see charging schemes�)�	Forbiddenz0Request forbidden -- authorization will not help�)z	Not FoundzNothing matches the given URIi�)zMethod Not Allowedz.Specified method is invalid for this resource.i�)zNot Acceptablez&URI not available in preferred format.i�)zProxy Authentication Requiredz8You must authenticate with this proxy before proceeding.i�)zRequest Timeoutz#Request timed out; try again later.i�)�ConflictzRequest conflict.i�)�Gonez6URI no longer exists and has been permanently removed.i�)zLength Requiredz#Client must specify Content-Length.i�)zPrecondition Failedz!Precondition in headers is false.i�)zRequest Entity Too LargezEntity is too large.rb)zRequest-URI Too LongzURI is too long.i�)zUnsupported Media Typez"Entity body in unsupported format.i�)zRequested Range Not SatisfiablezCannot satisfy request range.i�)zExpectation Failedz(Expect condition could not be satisfied.)zPrecondition Requiredz9The origin server requires the request to be conditional.)zToo Many RequestszPThe user has sent too many requests in a given amount of time ("rate limiting").)zRequest Header Fields Too LargezWThe server is unwilling to process the request because its header fields are too large.)zInternal Server ErrorzServer got itself in trouble)zNot Implementedz&Server does not support this operation)zBad Gatewayz,Invalid responses from another server/proxy.)zService Unavailablez8The server cannot process the request due to a high load)zGateway Timeoutz4The gateway server did not receive a timely response)zHTTP Version Not SupportedzCannot fulfill request.)zNetwork Authentication Requiredz8The client needs to authenticate to gain network access.)
i�i�i�i�rdi�i�i�r4i��N)r�r�)'r&r'r(�__doc__r�rUrDr��__version__r��DEFAULT_ERROR_MESSAGEr}�DEFAULT_ERROR_CONTENT_TYPEr�r=r[rTrorqrFr~r^rr�r_r�rkr�r�r�r�r�r�r�rJrL�HTTPMessagerOr{r*rrr
r
�s%������d�d�N�c�k�/�/�1�1�!�4�4�K�
!�;�.�N�0��3��)��O�O�O�b���$!�!�!�F&�&�&�A�A�A�A�>:�:�:�:�.�.�.�.�*�*�*�!�!�!�&�&�&�
A�A�A�A�(�(�(�(�(�(�,<�<�<�	�	�	�	����D�C�C�K�;�;�;�I�&�&�&�"���*�L�
H
��
>�H
��@�H
�
	�
:�H
�	�
9�
H
�	�A�H
�	�
N�H
�	�
A�H
�	�
E�H
�	�
<�H
�	�>�H
� 	�
N�!H
�"	�
B�#H
�$	�
E�%H
�&	�;�'H
�*	��+H
�0	�:�1H
�6	�:�7H
�H
�:	�<�;H
�>	�4�?H
�B	�B�CH
�F	�
;�GH
�H	�@�IH
�L	�
I�MH
�N	�/�OH
�R	�
G�SH
�T	�
.�UH
�V	�H�WH
�Z	�
G�[H
�\	�
I�]H
�^	�
A�_H
�`	�
9�aH
�b	�
M�cH
�d	�/�eH
�h	�:�iH
�H
�lK�>�N�G�8�
L�J�F�
F�J�MH
�H
�H
�I�I�Irc���eZdZdZdezZd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Ze
jse
j��e
j���Ze�d
dddd���d
S)�SimpleHTTPRequestHandleraWSimple HTTP request handler with GET and HEAD commands.

    This serves files from the current directory and any of its
    subdirectories.  The MIME type for files is determined by
    calling the .guess_type() method.

    The GET and HEAD requests are identical except that the HEAD
    request omits the actual contents of the file.

    zSimpleHTTP/c��|���}|r1|�||j��|���dSdS)zServe a GET request.N)�	send_head�copyfilerhr9�r#�fs  r�do_GETzSimpleHTTPRequestHandler.do_GET�sJ���N�N�����	��M�M�!�T�Z�(�(�(�
�G�G�I�I�I�I�I�	�	rc�^�|���}|r|���dSdS)zServe a HEAD request.N)r�r9r�s  r�do_HEADz SimpleHTTPRequestHandler.do_HEAD�s4���N�N�����	�
�G�G�I�I�I�I�I�	�	rc��|�|j��}d}tj�|��r�|j�d��sI|�d��|�d|jdz��|���dSdD]E}tj�||��}tj�	|��r|}n�F|�
|��S|�|��}	t|d��}n'#t$r|�dd��YdSwxYw|�d	��|�d
|��tj|�����}|�dt#|d����|�d
|�|j����|���|S)a{Common code for GET and HEAD commands.

        This sends the response code and MIME headers.

        Return value is either a file object (which has to be copied
        to the outputfile by the caller unless the command was HEAD,
        and must be closed by the caller under all circumstances), or
        None, in which case the caller has nothing further to do.

        Nr2r��Location)z
index.htmlz	index.htm�rbr�zFile not foundrx�Content-type�Content-Length�z
Last-Modified)�translate_pathrK�os�isdir�endswithr~rr�r��exists�list_directory�
guess_type�open�IOErrorrF�fstat�filenor@r��st_mtime)r#rKr��index�ctype�fss      rr�z"SimpleHTTPRequestHandler.send_head�s����"�"�4�9�-�-����
�7�=�=����
	1��9�%�%�c�*�*�
��"�"�3�'�'�'�� � ��T�Y��_�=�=�=�� � �"�"�"��t�2�
1�
1������T�5�1�1���7�>�>�%�(�(�� �D��E���*�*�4�0�0�0�����%�%��	��T�4� � �A�A���	�	�	��O�O�C�!1�2�2�2��4�4�	����	
���3���������/�/�/�
�X�a�h�h�j�j�
!�
!�����)�3�r�!�u�:�:�6�6�6�����$�*?�*?���*L�*L�M�M�M��������s�D#�# E�Ec	��	tj|��}n,#tj$r|�dd��YdSwxYw|�d����g}tjtj|j	����}tj��}d|z}|�d��|�d��|�d	|z��|�d
|z��|�d|z��|�d��|D]�}tj	�
||��}|x}	}
tj	�|��r
|d
z}	|d
z}
tj	�|��r|dz}	|�dtj|
���dtj|	���d�����|�d��d�
|���|��}t%j��}|�|��|�d��|�d��|�dd|z��|�dt1t3|������|���|S)z�Helper to produce a directory listing (absent index.html).

        Return value is either a file object, or None (indicating an
        error).  In either case, the headers are sent, making the
        interface the same as for send_head().

        r�zNo permission to list directoryNc�*�|���Sr�)rS)�as r�<lambda>z9SimpleHTTPRequestHandler.list_directory.<locals>.<lambda>�s�����	�	�r)�keyzDirectory listing for %szZ<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">z
<html>
<head>z@<meta http-equiv="Content-Type" content="text/html; charset=%s">z<title>%s</title>
</head>z<body>
<h1>%s</h1>z	<hr>
<ul>r2�@z
<li><a href="z">z	</a></li>z</ul>
<hr>
</body>
</html>
r�rrxr�ztext/html; charset=%sr�)r�listdir�errorrF�sortr�escape�urllib_parse�unquoterKr��getfilesystemencodingr�r�r�islink�quoter��io�BytesIOr��seekr~rr@rEr�)
r#rK�list�r�displaypath�enc�title�name�fullname�displayname�linkname�encodedr�s
             rrz'SimpleHTTPRequestHandler.list_directory�s���	��:�d�#�#�D�D���x�	�	�	��O�O�C�!B�C�C�C��4�4�	����	
�	�	�)�)�	�*�*�*����k�,�"6�t�y�"A�"A�B�B���'�)�)��*�[�8��	���<�	=�	=�	=�	���!�"�"�"�	���4�69�:�	;�	;�	;�	���-��5�6�6�6�	���&��.�/�/�/�	��������	P�	P�D��w�|�|�D�$�/�/�H�%)�)�K�(��w�}�}�X�&�&�
&�"�S�j���#�:���w�~�~�h�'�'�
)�"�S�j��
�H�H�H�#�)�(�3�3�3�3�T�[��5M�5M�5M�5M�O�
P�
P�
P�
P�
	
���2�3�3�3��)�)�A�,�,�%�%�c�*�*���J�L�L��	�������	���q�	�	�	����3��������)@�3�)F�G�G�G����)�3�s�7�|�|�+<�+<�=�=�=��������s��%A�Ac�:�|�dd��d}|�dd��d}tjtj|����}|�d��}td|��}t
j��}|D]�}tj�	|��\}}tj�|��\}}|tj
tjfvr�atj�||��}��|S)z�Translate a /-separated PATH to the local filename syntax.

        Components that mean special things to the local file system
        (e.g. drive or directory names) are ignored.  (XXX They should
        probably be diagnosed.)

        �?rr�#r2N)
rD�	posixpath�normpathrr�filterr�getcwdrK�
splitdrive�curdir�pardirr�)r#rKrV�word�drive�heads      rr�z'SimpleHTTPRequestHandler.translate_path
s����z�z�#�a� � ��#���z�z�#�a� � ��#���!�,�"6�t�"<�"<�=�=���
�
�3�����t�U�#�#���y�{�{���	,�	,�D��'�,�,�T�2�2�K�E�4�����t�,�,�J�D�$���	�2�9�-�-�-�x��7�<�<��d�+�+�D�D��rc�0�tj||��dS)a�Copy all data between two file objects.

        The SOURCE argument is a file object open for reading
        (or anything with a read() method) and the DESTINATION
        argument is a file object open for writing (or
        anything with a write() method).

        The only reason for overriding this would be to change
        the block size or perhaps to replace newlines by CRLF
        -- note however that this the default server uses this
        to copy binary data as well.

        N)�shutil�copyfileobj)r#�source�
outputfiles   rr�z!SimpleHTTPRequestHandler.copyfile#s��	��6�:�.�.�.�.�.rc���tj|��\}}||jvr
|j|S|���}||jvr
|j|S|jdS)a�Guess the type of a file.

        Argument is a PATH (a filename).

        Return value is a string of the form type/subtype,
        usable for a MIME Content-type header.

        The default implementation looks the file's extension
        up in the table self.extensions_map, using application/octet-stream
        as a default; however it would be permissible (if
        slow) to look inside the data to make a better guess.

        r8)r-�splitext�extensions_maprS)r#rK�base�exts    rrz#SimpleHTTPRequestHandler.guess_type3sk���&�t�,�,�	��c��$�%�%�%��&�s�+�+��i�i�k�k���$�%�%�%��&�s�+�+��&�r�*�*rzapplication/octet-streamz
text/plain)r8�.pyz.cz.hN)r&r'r(r�r�r�r�r�r�rr�r�r�	mimetypes�inited�init�	types_map�copyr>�updater*rrr�r��s�������	�	�#�[�0�N�������'�'�'�R2�2�2�h���,/�/�/� +�+�+�0����	������(�-�-�/�/�N����&����	
�
�����rr�c��|�d��}g}|dd�D]:}|dkr|����|r|dkr|�|���;|r<|���}|r%|dkr|���d}n|dkrd}nd}dd�|��z|f}d�|��}|S)a`
    Given a URL path, remove extra '/'s and '.' path elements and collapse
    any '..' references and returns a colllapsed path.

    Implements something akin to RFC-2396 5.2 step 6 to parse relative paths.
    The utility of this function is limited to is_cgi method and helps
    preventing some security attacks.

    Returns: A tuple of (head, tail) where tail is everything after the final /
    and head is everything before it.  Head will always start with a '/' and,
    if it contains anything else, never have a trailing '/'.

    Raises: IndexError if too many '..' occur within the path.

    r2N���z..r3r8)rD�popr�r�)rK�
path_parts�
head_parts�part�	tail_part�	splitpath�collapsed_paths       r�_url_collapse_pathrQXs���$���C���J��J��3�B�3��&�&���4�<�<��N�N�����
�	&�d�c�k�k����t�%�%�%���	��N�N�$�$�	��	��D� � ���� � � ��	�	��c�!�!��	���	��s�x�x�
�+�+�+�Y�7�I��X�X�i�(�(�N��rc��trtS	ddl}n#t$rYdSwxYw	|�d��dan>#t$r1dtd�|���D����zaYnwxYwtS)z$Internal routine to get nobody's uidrNrI�nobodyrrc3�&K�|]}|dV��
dS)rNr*)�.0r�s  r�	<genexpr>znobody_uid.<locals>.<genexpr>�s&����6�6�!��1��6�6�6�6�6�6r)rS�pwd�ImportError�getpwnamr|�max�getpwall)rWs r�
nobody_uidr\�s������
���
�
�
�
�������r�r�����7����h�'�'��*�����7�7�7��S�6�6�s�|�|�~�~�6�6�6�6�6�6����7�����Ms��
#�#�A�8A>�=A>c�@�tj|tj��S)zTest for executable file.)r�access�X_OK)rKs r�
executabler`�s��
�9�T�2�7�#�#�#rc�Z�eZdZdZeed��ZdZd�Zd�Z	d�Z
ddgZd	�Zd
�Z
d�ZdS)
�CGIHTTPRequestHandlerz�Complete HTTP server with GET, HEAD and POST commands.

    GET and HEAD also support running CGI scripts.

    The POST command is *only* implemented for CGI scripts.

    �forkrc��|���r|���dS|�dd��dS)zRServe a POST request.

        This is only implemented for CGI scripts.

        rdzCan only POST to CGI scriptsN)�is_cgi�run_cgirFr`s r�do_POSTzCGIHTTPRequestHandler.do_POST�sA���;�;�=�=�	A��L�L�N�N�N�N�N��O�O�C�!?�@�@�@�@�@rc��|���r|���St�|��S)z-Version of send_head that support CGI scripts)rerfr�r�r`s rr�zCGIHTTPRequestHandler.send_head�s4���;�;�=�=�	<��<�<�>�>�!�+�5�5�d�;�;�;rc��t|j��}|�dd��}|d|�||dzd�}}||jvr||f|_dSdS)a3Test whether self.path corresponds to a CGI script.

        Returns True and updates the cgi_info attribute to the tuple
        (dir, rest) if self.path requires running a CGI script.
        Returns False otherwise.

        If any exception is raised, the caller should assume that
        self.path was rejected as invalid and act accordingly.

        The default implementation tests whether the normalized url
        path begins with one of the strings in self.cgi_directories
        (and the next character is a '/' or the end of the string).

        r2rNTF)rQrK�find�cgi_directories�cgi_info)r#rP�dir_sepr6�tails     rrezCGIHTTPRequestHandler.is_cgi�sj��,�D�I�6�6�� �%�%�c�1�-�-��#�H�W�H�-�~�g�a�i�j�j�/I�d���4�'�'�'� �$�J�D�M��4��urz/cgi-binz/htbinc� �t|��S)z1Test whether argument path is an executable file.)r`)r#rKs  r�
is_executablez#CGIHTTPRequestHandler.is_executable�s���$���rc�r�tj�|��\}}|���dvS)z.Test whether argument path is a Python script.)rAz.pyw)rrKr=rS)r#rKr6rns    r�	is_pythonzCGIHTTPRequestHandler.is_python�s.���W�%�%�d�+�+�
��d��z�z�|�|��.�.rc��|j}|j\}}|�dt|��dz��}|dkr}|d|�}||dzd�}|�|��}t
j�|��r+||}}|�dt|��dz��}nn|dk�}|�d��}|dkr|d|�||dzd�}}nd}|�d��}|dkr|d|�||d�}}	n|d}}	|dz|	z}
|�|
��}t
j�|��s|�	dd|
z��dSt
j�
|��s|�	d	d
|
z��dS|�|
��}|js|s0|�
|��s|�	d	d|
z��dStjt
j��}
|���|
d<|jj|
d
<d|
d<|j|
d<t+|jj��|
d<|j|
d<t1j|��}||
d<|�|��|
d<|
|
d<|r||
d<|jd|
d<|j�d��}|�r|���}t|��dkr�ddl}ddl}|d|
d<|d� ��dkr�	|d�!d��}tDj#r)|�$|���%d��}n(|�&|���%d��}|�d��}t|��dkr|d|
d<n#|j'tPf$rYnwxYw|j�d���|j�)��|
d <n|jd|
d <|j�d!��}|r||
d"<|j�d#��}|r||
d$<g}|j�*d%��D]V}|dd�d&vr(|�+|�,�����6||d'd��d(��z}�Wd(�-|��|
d)<|j�d*��}|r||
d+<t]d|j�/d,g����}d-�-|��}|r||
d.<d/D]}|
�0|d���|�1d0d1��|�2��|�3d2d3��}|j�r�|	g}d4|vr|�+|��ti��}|j5�6��tj7��}|dkr�tj8|d��\}}tsj9|j:gggd��dr>|j:�;d��sn#tsj9|j:gggd��d�>|r|�<d5|��dS		tj=|��n#t
j>$rYnwxYwtj?|j:�@��d��tj?|j5�@��d��tjA|||
��dS#|j�B|jC|j��tjDd6��YdSxYwddlE}|g} |�|��rOt�jG}!|!� ���Hd7��r|!dd8�|!d9d�z}!|!d:g| z} d4|vr| �+|��|�Id;|�J| ����	t�|��}"n#t�t�f$rd}"YnwxYw|�N| |jO|jO|jO|
�<��}#|j� ��d=kr!|"dkr|j:�;|"��}$nd}$tsj9|j:jPgggd��drH|j:jP�Qd��sn(tsj9|j:jPgggd��d�H|#�R|$��\}%}&|j5�S|%��|&r|�<d>|&��|#jT�U��|#jV�U��|#jW}'|'r|�<d5|'��dS|�Id?��dS)@zExecute a CGI script.r2rrNr+r8r�zNo such CGI script (%r)r�z#CGI script is not a plain file (%r)z!CGI script is not executable (%r)�SERVER_SOFTWARE�SERVER_NAMEzCGI/1.1�GATEWAY_INTERFACE�SERVER_PROTOCOL�SERVER_PORT�REQUEST_METHOD�	PATH_INFO�PATH_TRANSLATED�SCRIPT_NAME�QUERY_STRING�REMOTE_ADDR�
authorizationr�	AUTH_TYPE�basic�ascii�:�REMOTE_USERzcontent-type�CONTENT_TYPEzcontent-length�CONTENT_LENGTH�referer�HTTP_REFERER�acceptz	

 ��,�HTTP_ACCEPTz
user-agent�HTTP_USER_AGENT�cookiez, �HTTP_COOKIE)r}�REMOTE_HOSTr�r�r�r�rxzScript output follows�+r��=zCGI script exit status %#x�zw.exe������z-uzcommand: %s)�stdin�stdoutr��env�postz%szCGI script exited OK)XrKrlrjrEr�rr�rfindrrF�isfilerr�	have_forkrprF�deepcopy�environr��serverr!rJr@r"r<rrr�rPrRrD�base64�binasciirSr�r�PY3�decodebytes�decode�decodestring�Error�UnicodeError�get_content_type�getallmatchingheadersr��stripr�r/�get_all�
setdefaultr~r_rr\rhrirc�waitpid�selectrN�readrk�setuidr�dup2r	�execve�handle_error�request�_exit�
subprocessr�r`rr��list2cmdlinerH�	TypeErrorrG�Popen�PIPE�_sock�recv�communicater�r�r9r��
returncode)(r#rK�dir�rest�i�nextdir�nextrest�	scriptdir�query�script�
scriptname�
scriptfile�ispyr��uqrestrr�r��lengthr�r��line�ua�co�
cookie_str�k�
decoded_queryr�rS�pid�stsr��cmdline�interp�nbytes�p�datar�r��statuss(                                        rrfzCGIHTTPRequestHandler.run_cgi�s�
���y���M�	��T��I�I�c�3�s�8�8�a�<�(�(���1�f�f��2�A�2�h�G��A�a�C�D�D�z�H��+�+�G�4�4�I��w�}�}�Y�'�'�
�#�X�T���I�I�c�3�s�8�8�a�<�0�0�����1�f�f�
�J�J�s�O�O����6�6��r��r�(�D��1����J�%�D�D��E�
�I�I�c�N�N����6�6�����8�T�!�"�"�X�D�F�F���D�F��3�Y��'�
��(�(��4�4�
��w�~�~�j�)�)�	��O�O�C�!:�Z�!G�H�H�H��F��w�~�~�j�)�)�	��O�O�C�!F�&�"'�
(�
(�
(��F��~�~�j�)�)���>�	��	��%�%�j�1�1�
�����%H� *�&+�,�,�,����m�B�J�'�'��!%�!4�!4�!6�!6����!�[�4��M��#,��� �!%�!6���� ���!8�9�9��M�� $������%�d�+�+��!��K��!%�!4�!4�V�!<�!<����'��M���	(�"'�C���!�0��3��M����(�(��9�9�
��	B�)�/�/�1�1�M��=�!�!�Q�&�&�'�'�'�'�'�'�'�'�#0��#3��K� � ��#�)�)�+�+�w�6�6�B�(5�a�(8�(?�(?��(H�(H�
� �9�<�,2�,>�,>�}�,M�,M�,2�F�7�O�O�*�M�-3�,?�,?�
�,N�,N�,2�F�7�O�O�*�
)6�(;�(;�C�(@�(@�
��}�-�-��2�2�1>�q�1A�C�
�.���%�N�L�9�����������<���N�+�+�3�"&�,�"?�"?�"A�"A�C����"&�,�~�">�C�����!�!�"2�3�3���	+�$*�C� �!��,�"�"�9�-�-���	*�")�C������L�6�6�x�@�@�	6�	6�D��B�Q�B�x�9�$�$��
�
�d�j�j�l�l�+�+�+�+��$�q�r�r�(�.�.��"5�"5�5��� �X�X�f�-�-��M��
�\�
�
�l�
+�
+��
�	(�%'�C�!�"�
�D�$�,�.�.�x��<�<�
=�
=���Y�Y�r�]�]�
��	,�!+�C�
��D�	"�	"�A��N�N�1�b�!�!�!�!����3� 7�8�8�8��������
�
�c�3�/�/�
��>�H	9��8�D��-�'�'����M�*�*�*��\�\�F��J�������'�)�)�C��a�x�x��:�c�1�-�-���S��m�T�Z�L�"�b�!�<�<�Q�?���:�?�?�1�-�-����m�T�Z�L�"�b�!�<�<�Q�?���F��N�N�#?��E�E�E���

���I�f�%�%�%�%���x�����D��������
�)�)�+�+�Q�/�/�/����
�)�)�+�+�Q�/�/�/��	�*�d�C�0�0�0�0�0��
���(�(���t�7J�K�K�K����
�
�
�
�
�
����
����!�l�G��~�~�j�)�)�
3�����<�<�>�>�*�*�7�3�3�7�#�C�R�C�[�6�"�#�#�;�6�F�!�4�.�7�2���%������u�%�%�%����]�J�,C�,C�G�,L�,L�M�M�M�
��V�������z�*�
�
�
�����
����� � ��'1��(2��(2��'*�	!�#�#�A��|�!�!�#�#�v�-�-�&�1�*�*��z���v�.�.������-���!1� 2�B��A�>�>�q�A�
��z�'�,�,�Q�/�/����-���!1� 2�B��A�>�>�q�A�
��]�]�4�0�0�N�F�F��J���V�$�$�$��
-����t�V�,�,�,�
�H�N�N����
�H�N�N�����\�F��
9����;�V�D�D�D�D�D�� � �!7�8�8�8�8�8sP�?A8O+�+O?�>O?�[%�$]*�%[7�4]*�6[7�7A1]*�*;^(�a)�)a?�>a?N)r&r'r(r�rfrr��rbufsizergr�rerkrprrrfr*rrrbrb�s������������F�#�#�I��H�
A�
A�
A�<�<�<����0"�8�,�O� � � �/�/�/�
D9�D9�D9�D9�D9rrbr�i@c�^�d|f}||_|||��}|j���}td|dd|dd��	|���dS#t
$r;td��|���tjd��YdSwxYw)	zTest the HTTP request handler class.

    This runs an HTTP server on port 8000 (or the first command line
    argument).

    r8zServing HTTP onrr%rz...z&
Keyboard interrupt received, exiting.N)	rJrr�print�
serve_forever�KeyboardInterrupt�server_closer��exit)�HandlerClass�ServerClass�protocolr%�server_address�httpd�sas       r�testr��s����$�Z�N�$,�L�!��K���5�5�E�	��	!�	!�	#�	#�B�	�
�R��U�F�B�q�E�5�9�9�9��
�������������
�7�8�8�8�
������������������s�A'�'AB,�+B,�__main__z--cgi�
store_truezRun as CGI Server)�action�helpr%�storer+z&Specify alternate port [default: 8000])r��default�type�nargsr�)r�r%)6r��
__future__rrrr�futurer�future.builtinsr��__all__�future.backportsr�future.backports.httpr
rL�future.backports.urllibrrrrrBrr-r�r8rr�r�rF�argparser�r�rrr	�StreamRequestHandlerr
r�rQrSr\r`rbr�r&�ArgumentParser�parser�add_argumentrH�
parse_argsr��cgir%r*rr�<module>r�sB��!�!�F:�:�:�:�:�:�:�:�:�:�:�:�����������f���1�
2��!�!�!�!�!�!�7�7�7�7�7�7�9�9�9�9�9�9�)�)�)�)�)�)�	�	�	�	�����	�	�	�	�����
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
���������������"7��P�P�P�	 �	 �	 �	 �	 ��'�	 �	 �	 �~
�~
�~
�~
�~
�\�>�~
�~
�~
�B�����5����H'�'�'�V
��
�
�
� $�$�$�
K9�K9�K9�K9�K9�4�K9�K9�K9�\/�!�J�T�����,�z���
$�X�
$�
&�
&�F�
�����/��1�1�1�
����w� $�3�!�E��G�G�G������D��x�D���/�d�i�@�@�@�@�@�@���2���C�C�C�C�C�C��r

Hacked By AnonymousFox1.0, Coded By AnonymousFox