Your IP : 3.139.104.140


Current Path : /opt/alt/python312/lib64/python3.12/http/__pycache__/
Upload File :
Current File : //opt/alt/python312/lib64/python3.12/http/__pycache__/server.cpython-312.opt-2.pyc

�

�Q�f����f�	dZgd�ZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlmZdZdZGd�dej2�ZGd	�d
ej6e�ZGd�dej:�ZGd
�de�Zd�Z da!d�Z"d�Z#Gd�de�Z$d�Z%eedddfd�Z&e'dk(r�ddl(Z(ddl)Z)e(jT�Z+e+jYddd��e+jYdddd �!�e+jYd"d#ejZ�d$�%�e+jYd&d'd(dd)�*�e+jYd+de.d,d-�.�e+j_�Z0e0jbre$Z2neZ2Gd/�d0e�Z3e&e2e3e0jhe0jje0jl�1�yy)2z0.6)�
HTTPServer�ThreadingHTTPServer�BaseHTTPRequestHandler�SimpleHTTPRequestHandler�CGIHTTPRequestHandler�N)�
HTTPStatusaD<!DOCTYPE HTML>
<html lang="en">
    <head>
        <meta 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��eZdZdZd�Zy)r�c��	tjj|�|jdd\}}t	j
|�|_||_y)N�)�socketserver�	TCPServer�server_bind�server_address�socket�getfqdn�server_name�server_port)�self�host�ports   �2/opt/alt/python312/lib64/python3.12/http/server.pyrzHTTPServer.server_bind�sH��<����*�*�4�0��(�(��!�,�
��d�!�>�>�$�/������N)�__name__�
__module__�__qualname__�allow_reuse_addressr�rrrr�s
���� rrc��eZdZdZy)rTN)rrr�daemon_threadsrrrrr�s���Nrrc
�L�eZdZ	dejj�dzZdezZe	Z
eZdZ
d�Zd�Zd�Zd�Zd!d
�Zd"d�Zd"d�Zd
�Zd�Zd�Zd#d�Zd�Zej7ej:ed�edd��D��cic]	}|d|d����c}}�Zdee d�<d�Z!d�Z"d"d�Z#d�Z$gd�Z%gd�Z&d�Z'd Z(e)jTjVZ,e-j\j_�D��cic]}||j`|jbf��c}}Z2y	cc}}wcc}}w)$rzPython/rz	BaseHTTP/�HTTP/0.9c�0�	d|_|jx|_}d|_t	|j
d�}|j
d�}||_|j�}t|�dk(ryt|�dk\r�|d}	|jd�st�|jd	d
�d
}|jd�}t|�dk7rt�td
�|D��rtd��td�|D��rtd��t|d�t|d
�f}|dk\r|j$dk\rd|_|dk\r$|jt j&d|z�y||_dt|�cxkrdks&n|jt j"d|z�y|dd\}}t|�dk(r0d|_|dk7r$|jt j"d|z�y||c|_|_|j(jd�r#d	|j(j+d	�z|_	t,j.j1|j2|j4��|_|j6j?dd�}	|	jA�dk(rd|_n)|	jA�d k(r|j$dk\rd|_|j6j?d!d�}
|
jA�d"k(r/|j$dk\r |jdk\r|jC�syy#ttf$r&|jt j"d|z�YywxYw#t,j.j8$r4}|jt j:dt	|��Yd}~yd}~wt,j.j<$r4}|jt j:dt	|��Yd}~yd}~wwxYw)#NTz
iso-8859-1�
rF����zHTTP/�/r
�.rc3�>K�|]}|j����y�w�N)�isdigit��.0�	components  r�	<genexpr>z7BaseHTTPRequestHandler.parse_request.<locals>.<genexpr>/s����O��9�9�,�,�.�.��s�znon digit in http versionc3�8K�|]}t|�dkD���y�w)�
N)�lenr,s  rr/z7BaseHTTPRequestHandler.parse_request.<locals>.<genexpr>1s����K�N�y�s�9�~��*�N�s�z unreasonable length http versionzBad request version (%r))r
r
zHTTP/1.1)rrzInvalid HTTP version (%s)zBad request syntax (%r)�GETzBad HTTP/0.9 request type (%r)z//)�_classz
Line too longzToo many headers�
Connection��close�
keep-alive�Expectz100-continue)"�command�default_request_version�request_version�close_connection�str�raw_requestline�rstrip�requestline�splitr2�
startswith�
ValueError�any�int�
IndexError�
send_errorr�BAD_REQUEST�protocol_version�HTTP_VERSION_NOT_SUPPORTED�path�lstrip�http�client�
parse_headers�rfile�MessageClass�headers�LineTooLong�REQUEST_HEADER_FIELDS_TOO_LARGE�
HTTPException�get�lower�handle_expect_100)r�versionrA�words�base_version_number�version_numberr:rL�err�conntype�expects           r�
parse_requestz$BaseHTTPRequestHandler.parse_requests���		����)-�)E�)E�E���w� $����$�.�.��=��!�(�(��0��&����!�!�#���u�:��?���u�:��?��B�i�G�
��)�)�'�2�$�$�&-�m�m�C��&;�A�&>�#�!4�!:�!:�3�!?���~�&�!�+�$�$��O��O�O�$�%@�A�A��K�N�K�K�$�%G�H�H�!$�^�A�%6�!7��^�A�=N�9O�!O����'�D�,A�,A�Z�,O�(-��%���'�����9�9�/�2E�E�G��#*�D� ��C��J�#�!�#��O�O��&�&�)�K�7�
9���b�q�	�
����u�:��?�$(�D�!��%������*�*�4�w�>�@��")�4����d�i��9�9����%��d�i�i�.�.�s�3�3�D�I�	��;�;�4�4�T�Z�Z�<@�<M�<M�5�O�D�L� �<�<�#�#�L�"�5���>�>��w�&�$(�D�!��n�n��,�.��#�#�z�1�$)�D�!����!�!�(�B�/���L�L�N�n�,��%�%��3��$�$�
�2��)�)�+����G�
�+�
�����*�*�.��8�:��	
��P�{�{�&�&�	��O�O��:�:���C��
����{�{�(�(�	��O�O��:�:�"��C��
�
��
	�s7�B'L=�:M5�=2M2�1M2�5P�*O� P�!*P�Pc�d�	|jtj�|j�y�NT)�send_response_onlyr�CONTINUE�end_headers�rs rrYz(BaseHTTPRequestHandler.handle_expect_100ys,��	�	
���
� 3� 3�4�����rc�v�		|jjd�|_t|j�dkDr5d|_d|_d|_|jtj�y|jsd|_
y|j�syd|jz}t||�s.|jtjd|jz�yt||�}|�|jj!�y#t"$r#}|j%d|�d|_
Yd}~yd}~wwxYw)Niir6T�do_zUnsupported method (%r)zRequest timed out: %r)rQ�readliner?r2rAr<r:rHr�REQUEST_URI_TOO_LONGr=ra�hasattr�NOT_IMPLEMENTED�getattr�wfile�flush�TimeoutError�	log_error)r�mname�method�es    r�handle_one_requestz)BaseHTTPRequestHandler.handle_one_request�s��	�	�#'�:�:�#6�#6�u�#=�D� ��4�'�'�(�5�0�#%�� �')��$�!������
� ?� ?�@���'�'�(,��%���%�%�'���D�L�L�(�E��4��'�����.�.�-����<�>���T�5�)�F��H��J�J������	��N�N�2�A�6�$(�D�!���		�s1�A,D�0D�D�AD�-D�	D8�D3�3D8c��	d|_|j�|js|j�|js�yyrc)r=rvrgs r�handlezBaseHTTPRequestHandler.handle�s9��4� $������!��'�'��#�#�%��'�'rNc���		|j|\}}|�|}|�|}|jd||�|j||�|j	dd�d}|dk\r�|t
jt
jt
jfvr�|j|tj|d��tj|d��d�z}|jd	d
�}|j	d|j�|j	dtt|���|j!�|j"d
k7r|r|j$j'|�yyy#t$r	d\}}Y��VwxYw)N)�???rzzcode %d, message %sr5r7��F��quote)�code�message�explainzUTF-8�replacezContent-Type�Content-Length�HEAD)�	responses�KeyErrorrr�
send_response�send_headerr�
NO_CONTENT�
RESET_CONTENT�NOT_MODIFIED�error_message_format�html�escape�encode�error_content_typer>r2rfr:ro�write)rr~rr��shortmsg�longmsg�body�contents        rrHz!BaseHTTPRequestHandler.send_error�sa��	�"	-� $���t� 4��H�g��?��G��?��G����,�d�G�<����4��)�����w�/�
���C�K���.�.�#�1�1�#�0�0�2�
2�
�0�0���;�;�w�e�<��;�;�w�e�<�4��G�
�>�>�'�9�5�D����^�T�-D�-D�E����-�s�3�t�9�~�>������<�<�6�!�d��J�J���T�"�'+�!��=�	-� ,��H�g�	-�s�E�E,�+E,c���	|j|�|j||�|jd|j��|jd|j	��y)N�Server�Date)�log_requestrdr��version_string�date_time_string�rr~rs   rr�z$BaseHTTPRequestHandler.send_response�sY��	�	
���������g�.�����4�#6�#6�#8�9������!6�!6�!8�9rc��	|jdk7rt|�#||jvr|j|d}nd}t|d�sg|_|jj	d|j
||fzj
dd��yy)Nr"rr6�_headers_bufferz
%s %d %s
�latin-1�strict)r<r�rlr��appendrJr�r�s   rrdz)BaseHTTPRequestHandler.send_response_only�s���,����:�-����4�>�>�)�"�n�n�T�2�1�5�G� �G��4�!2�3�')��$�� � �'�'���*�*�D�'�:�*;�<B�F�!�8�=-�
.�.rc�@�	|jdk7rDt|d�sg|_|jj|�d|�d�j	dd��|j�dk(r7|j�dk(rd	|_y|j�d
k(rd|_yyy)Nr"r�z: r$r�r��
connectionr7Tr8F)r<rlr�r�r�rXr=)r�keyword�values   rr�z"BaseHTTPRequestHandler.send_headers���7����:�-��4�!2�3�')��$�� � �'�'�!(�%�0�8�8��H�M�
O��=�=�?�l�*��{�{�}��'�(,��%�����,�.�(-��%�/�+rc�|�	|jdk7r,|jjd�|j�yy)Nr"s
)r<r�r��
flush_headersrgs rrfz"BaseHTTPRequestHandler.end_headerss8��:����:�-�� � �'�'��0���� �.rc��t|d�r<|jjdj|j��g|_yy)Nr�r)rlror��joinr�rgs rr�z$BaseHTTPRequestHandler.flush_headerss;���4�*�+��J�J���S�X�X�d�&:�&:�;�<�#%�D� �,rc��	t|t�r|j}|jd|jt|�t|��y)Nz
"%s" %s %s)�
isinstancerr��log_messagerAr>)rr~�sizes   rr�z"BaseHTTPRequestHandler.log_request!sB��	�
�d�J�'��:�:�D������)�)�3�t�9�c�$�i�	Arc�,�	|j|g|���yr*)r�)r�format�argss   rrrz BaseHTTPRequestHandler.log_error,s��		�	�����'�$�'r� ��z\x�02xz\\�\c	���	||z}tjj|j��d|j	��d|j|j��d��y)Nz - - [z] �
)�sys�stderrr��address_string�log_date_time_string�	translate�_control_char_table)rr�r�rs    rr�z"BaseHTTPRequestHandler.log_message?sW��	�&�4�-���
�
����-�-�/��3�3�5�!�+�+�D�,D�,D�E�G�	Hrc�<�	|jdz|jzS)N� )�server_version�sys_versionrgs rr�z%BaseHTTPRequestHandler.version_stringYs!��8��"�"�S�(�4�+;�+;�;�;rc�r�	|�tj�}tjj|d��S)NT)�usegmt)�time�email�utils�
formatdate)r�	timestamps  rr�z'BaseHTTPRequestHandler.date_time_string]s0��N����	�	��I��{�{�%�%�i��%�=�=rc	��	tj�}tj|�\	}}}}}}}}	}
d||j|||||fz}|S)Nz%02d/%3s/%04d %02d:%02d:%02d)r��	localtime�	monthname)r�now�year�month�day�hh�mm�ss�x�y�z�ss            rr�z+BaseHTTPRequestHandler.log_date_time_stringcs[��<��i�i�k��04���s�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�Nr)�client_addressrgs rr�z%BaseHTTPRequestHandler.address_stringqs��(��"�"�1�%�%r�HTTP/1.0)NNr*)�-r�)3rrrr�rZrBr��__version__r��DEFAULT_ERROR_MESSAGEr��DEFAULT_ERROR_CONTENT_TYPEr�r;rarYrvrxrHr�rdr�rfr�r�rrr>�	maketrans�	itertools�chain�ranger��ordr�r�r�r��weekdaynamer�r�rJrNrO�HTTPMessagerRr�__members__�values�phrase�descriptionr�)r-�c�vs000rrr�sq��d�N�c�k�k�/�/�1�!�4�4�K�
!�;�.�N�0��3��)��l�\�$#�J&�3#�j:�.�.�!�&�
	A�(��-�-�'6�y���u�T�{�E�$�t�DT�'U�V�'U�!�Q�2�a��W�
�
�'U�V�X��%*���D�	�"�H�4<�>��D�K�;�I�&�"���;�;�*�*�L�
�'�'�.�.�0��0�A�	
�A�H�H�a�m�m�$�$�0��I��I
W��Hs�D
�5 D rc�p��eZdZ	dezZdZddddd�xZZdd	��fd
�
Zd�Z	d�Z
d
�Zd�Zd�Z
d�Zd�Z�xZS)rzSimpleHTTP/)z
index.htmlz	index.htmzapplication/gzip�application/octet-streamzapplication/x-bzip2zapplication/x-xz)z.gzz.Zz.bz2z.xzN��	directoryc���|�tj�}tj|�|_t	�|�|i|��yr*)�os�getcwd�fspathr�super�__init__)rrr��kwargs�	__class__s    �rrz!SimpleHTTPRequestHandler.__init__�s6������	�	��I����9�-���
���$�)�&�)rc��	|j�}|r.	|j||j�|j�yy#|j�wxYwr*)�	send_head�copyfileror7�r�fs  r�do_GETzSimpleHTTPRequestHandler.do_GET�sF��"��N�N����
��
�
�a����,����	�	
�����	�s�A�Ac�L�	|j�}|r|j�yyr*)rr7r
s  r�do_HEADz SimpleHTTPRequestHandler.do_HEAD�s"��#��N�N����
�G�G�I�
rc�0�	|j|j�}d}tjj|��r5tj
j
|j�}|jjd�s�|jtj�|d|d|ddz|d|df}tj
j|�}|jd|�|jdd	�|j�y|jD]E}tjj||�}tjj!|�s�C|}n|j#|�S|j%|�}|jd�r!|j'tj(d
�y	t+|d�}	tj.|j1��}d|j2v�r1d
|j2v�r"	t4j6j9|j2d�}	|	j:�*|	j=t>j@jB��}	|	j:t>j@jBur�t>j>jE|jFt>j@jB�}
|
j=d��}
|
|	kr@|jtjH�|j�|jK�y|jtjT�|jd|�|jdtW|d��|jd|jY|jF��|j�|S#t,$r#|j'tj(d
�YywxYw#tLtNtPtRf$rY��wxYw#|jK��xYw)Nr'rr
rr%��Locationr��0zFile not found�rbzIf-Modified-Sincez
If-None-Match)�tzinfo)�microsecond�Content-type�z
Last-Modified)-�translate_pathrLr�isdir�urllib�parse�urlsplit�endswithr�r�MOVED_PERMANENTLY�
urlunsplitr�rf�index_pagesr��isfile�list_directory�
guess_typerH�	NOT_FOUND�open�OSError�fstat�filenorSr�r��parsedate_to_datetimerr��datetime�timezone�utc�
fromtimestamp�st_mtimer�r7�	TypeErrorrG�
OverflowErrorrD�OKr>r�)rrLr�parts�	new_parts�new_url�index�ctype�fs�ims�
last_modifs           rrz"SimpleHTTPRequestHandler.send_head�sG��		��"�"�4�9�9�-����
�7�7�=�=����L�L�)�)�$�)�)�4�E��:�:�&�&�s�+��"�"�:�#?�#?�@�"�1�X�u�Q�x��q��C��"�1�X�u�Q�x�1�	� �,�,�1�1�)�<��� � ��W�5�� � �!1�3�7�� � �"���)�)�������T�5�1���7�7�>�>�%�(� �D��	*��*�*�4�0�0�����%���=�=����O�O�J�0�0�2B�C��	��T�4� �A�
'	����!�(�(�*�%�B�#�t�|�|�3�'�t�|�|�;�(��+�+�;�;����%8�9�;�C��z�z�)�"�k�k��1B�1B�1F�1F�k�G���z�z�X�%6�%6�%:�%:�:�%-�%6�%6�%D�%D��K�K��):�):�)>�)>�&@�
�&0�%7�%7�A�%7�%F�
�%��,� �.�.�z�/F�/F�G� �,�,�.��G�G�I�#'����z�}�}�-����^�U�3����-�s�2�a�5�z�:����_��%�%�b�k�k�2�
4������H��Q�	��O�O�J�0�0�2B�C��	��"�:�}�j�I�����8	�
�G�G�I��sK�8N4�AP�,O#�3C4P�(BP�4)O �O �#O?�<P�>O?�?P�Pc
��		tj|�}|j
d���g}	tjj|jd��}tj|d��}tj�}d|��}|j!d	�|j!d
�|j!d�|j!d|�d
��|j!d|�d��|j!d|�d��|j!d�|D]�}tjj#||�}|x}	}
tjj%|�r
|dz}	|dz}
tjj'|�r|dz}	|j!dtjj)|
d���d
tj|	d���d����|j!d�dj#|�j+|d�}t-j.�}|j1|�|j3d�|j5tj6�|j9dd|z�|j9dt;t=|���|j?�|S#t$r#|jtj
d�YywxYw#t$r-tjj|j�}Y���wxYw)NzNo permission to list directoryc�"�|j�Sr*)rX)�as r�<lambda>z9SimpleHTTPRequestHandler.list_directory.<locals>.<lambda>s
�����	r)�key�
surrogatepass��errorsFr|zDirectory listing for z<!DOCTYPE HTML>z<html lang="en">z<head>z<meta charset="z">z<title>z</title>
</head>z<body>
<h1>z</h1>z	<hr>
<ul>r'�@z
<li><a href="z	</a></li>z</ul>
<hr>
</body>
</html>
r��surrogateescaperrztext/html; charset=%sr�) r�listdirr)rHrr'�sortrr�unquoterL�UnicodeDecodeErrorr�r�r��getfilesystemencodingr�r�r�islinkr}r��io�BytesIOr��seekr�r4r�r>r2rf)
rrL�list�r�displaypath�enc�title�name�fullname�displayname�linkname�encodedrs
             rr%z'SimpleHTTPRequestHandler.list_directory	s���	�	��:�:�d�#�D�	
�	�	�)�	�*���	:� �,�,�.�.�t�y�y�6E�/�G�K��k�k�+�U�;���'�'�)��(��
�6��	���"�#�	���#�$�	�����	���?�3�%�r�*�+�	���7�5�'�!2�3�4�	���<��w�e�,�-�	������D��w�w�|�|�D�$�/�H�%)�)�K�(��w�w�}�}�X�&�"�S�j���#�:���w�w�~�~�h�'�"�S�j��
�H�H��|�|�)�)�(�1@�*�B��{�{�;�e�<�>�
?��	
���2�3��)�)�A�,�%�%�c�+<�=���J�J�L��	�����	���q�	����:�=�=�)�����)@�3�)F�G����)�3�s�7�|�+<�=��������[�	��O�O��$�$�1�
3��		��"�	:� �,�,�.�.�t�y�y�9�K�	:�s"�J"�+K�")K�
K�2L�Lc��	|jdd�d}|jdd�d}|j�jd�}	tjj|d��}tj|�}|jd�}td|�}|j}|D]d}tjj|�s"|tjtjfvr�Etjj!||�}�f|r|dz
}|S#t$r"tjj|�}Y��wxYw)N�?r
r�#r'rBrC)rBr@r rrrIrJ�	posixpath�normpath�filterrrrL�dirname�curdir�pardirr�)rrL�trailing_slashr[�words     rrz'SimpleHTTPRequestHandler.translate_pathBs��	��z�z�#�a� ��#���z�z�#�a� ��#������/�/��4��	.��<�<�'�'��_�'�E�D��!�!�$�'���
�
�3����t�U�#���~�~���D��w�w���t�$�����B�I�I�0F�(F���7�7�<�<��d�+�D�	�
��C�K�D����"�	.��<�<�'�'��-�D�	.�s�!D�(E�Ec�2�	tj||�yr*)�shutil�copyfileobj)r�source�
outputfiles   rrz!SimpleHTTPRequestHandler.copyfile`s��	�	���6�:�.rc��	tj|�\}}||jvr|j|S|j�}||jvr|j|St	j
|�\}}|r|Sy)Nr�)r]�splitext�extensions_maprX�	mimetypesr&)rrL�base�ext�guess�_s      rr&z#SimpleHTTPRequestHandler.guess_typeps���	��&�&�t�,�	��c��$�%�%�%��&�&�s�+�+��i�i�k���$�%�%�%��&�&�s�+�+��'�'��-���q���L�)r)rrrr�r�r#rl�_encodings_map_defaultrrrrr%rrr&�
__classcell__�r	s@rrr�sd���	�#�[�0�N�-�K�!�(�%�!�	/��N�+�)-�*���V�p7�r�</� *rrc���	|jd�\}}}tjj|�}|j	d�}g}|ddD]2}|dk(r|j��|s�|dk7s�"|j
|��4|r2|j�}|r"|dk(r|j�d}n
|dk(rd}nd}|rdj||f�}ddj|�z|f}dj|�}|S)Nr[r'r&z..r(r6)�	partitionrrrIrB�popr�r�)	rLrq�query�
path_parts�
head_parts�part�	tail_part�	splitpath�collapsed_paths	         r�_url_collapse_pathr�s�����^�^�C�(�N�D�!�U��<�<����%�D����C��J��J��3�B����4�<��N�N��
�d�c�k����t�%�	 �
��N�N�$�	���D� ���� ��	��c�!��	��	���H�H�i��/�0�	��s�x�x�
�+�+�Y�7�I��X�X�i�(�N��rc���	trtS	ddl}	|jd�datS#t$rYywxYw#t$r+dtd�|j
�D��zaYtSwxYw)Nrr&�nobodyrr
c3�&K�|]	}|d���y�w)rNr)r-r�s  rr/znobody_uid.<locals>.<genexpr>�s����6�~�!��1��~�s�)r��pwd�ImportError�getpwnamr��max�getpwall)r�s r�
nobody_uidr��sx��.�
��
���7����h�'��*���M��
������7��S�6�s�|�|�~�6�6�6���M�7�s�.�=�	:�:�,A1�0A1c�L�	tj|tj�Sr*)r�access�X_OK)rLs r�
executabler��s��#�
�9�9�T�2�7�7�#�#rc�P�eZdZ	eed�ZdZd�Zd�Zd�Z	ddgZ
d�Zd	�Zd
�Z
y)r�forkrc��	|j�r|j�y|jtjd�y)NzCan only POST to CGI scripts)�is_cgi�run_cgirHrrmrgs r�do_POSTzCGIHTTPRequestHandler.do_POST�s3��	��;�;�=��L�L�N��O�O��*�*�.�
0rc�n�	|j�r|j�Stj|�Sr*)r�r�rrrgs rrzCGIHTTPRequestHandler.send_head�s+��;��;�;�=��<�<�>�!�+�5�5�d�;�;rc��	t|j�}|jdd�}|dkDr=|d||jvr,|jd|dz�}|dkDr|d||jvr�,|dkDr|d|||dzd}}||f|_yy)Nr'r
rTF)rrL�find�cgi_directories�cgi_info)rr~�dir_sep�head�tails     rr�zCGIHTTPRequestHandler.is_cgi�s���
	�,�D�I�I�6�� �%�%�c�1�-����k�.��'�":�d�>R�>R�"R�$�)�)�#�w�q�y�9�G���k�.��'�":�d�>R�>R�"R��Q�;�'���1�>�'�!�)�*�3M�$�D� �$�J�D�M��rz/cgi-binz/htbinc��	t|�Sr*)r�)rrLs  r�
is_executablez#CGIHTTPRequestHandler.is_executables��?��$��rc�l�	tjj|�\}}|j�dvS)N)z.pyz.pyw)rrLrkrX)rrLr�r�s    r�	is_pythonzCGIHTTPRequestHandler.is_pythons.��<��W�W�%�%�d�+�
��d��z�z�|��.�.rc��	|j\}}|dz|z}|jdt|�dz�}|dk\rg|d|}||dzd}|j|�}tj
j
|�r#||}}|jdt|�dz�}nn|dk\r�g|jd�\}}}	|jd�}|dk\r|d|||d}}
n|d}}
|dz|
z}|j|�}tj
j|�s$|jtjd|z�ytj
j|�s$|jtjd|z�y|j|�}
|js|
s5|j!|�s$|jtjd|z�yt#j$tj&�}|j)�|d	<|j*j,|d
<d|d<|j.|d
<t1|j*j2�|d<|j4|d<t6j8j;|�}||d<|j|�|d<||d<|	|d<|j<d|d<|j>jAd�}|r�|jC�}t|�dk(r�ddl"}ddl#}|d|d<|djI�dk(r]	|djKd�}|jM|�jOd�}|jCd�}t|�dk(r	|d|d<	|j>jAd��|j>jU�|d<n|j>d|d<|j>jAd�}|r||d<|j>jAd �}|r||d!<|j>jWd"d#�}d$jY|�|d%<|j>jAd&�}|r||d'<t[d|j>jWd(g��}d)jY|�}|r||d*<d+D]}|j]|d��|j_tj`d,�|jc�|	jed-d.�}|j�r�|
g}d/|vr|jg|�ti�}|jjjm�t	jn�}|dk7r�t	jp|d�\}}tsjr|jtgggd�drC|jtjwd�sn'tsjr|jtgggd�dr�Ct	jx|�}|r|j{d0|���y		t	j||�t	j�|jtj��d�t	j�|jjj��d�t	j�|||�yddlF} |g}!|j|�rAt�j�}"|"jI�j�d2�r|"dd3|"d4dz}"|"d5g|!z}!d/|	vr|!jg|	�|j�d6| j�|!��	t�|�}#| j�|!| j�| j�| j�|�7�}$|j4jI�d8k(r!|#dkDr|jtjw|#�}%nd}%tsjr|jtj�gggd�drW|jtj�j�d�sn1tsjr|jtj�gggd�dr�W|$j�|%�\}&}'|jjj�|&�|'r|j{d9|'�|$j�j��|$j�j��|$j�}(|(r|j{d:|(�y|j�d;�y#|jPtRf$rY��mwxYw#t~$rY���wxYw#|j*j�|j�|j<�t	j�d1�YyxYw#t�t�f$rd}#Y��1wxYw)<Nr'r
rr[r6zNo such CGI script (%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�acceptr�,�HTTP_ACCEPTz
user-agent�HTTP_USER_AGENT�cookiez, �HTTP_COOKIE)r��REMOTE_HOSTr�r�r�r�zScript output follows�+r��=zCGI script exit code r�zw.exe������z-uzcommand: %s)�stdin�stdoutr��env�postz%szCGI script exit status %#xzCGI script exited OK)Yr�r�r2rrrLrrv�existsrHrr'r$�	FORBIDDENr��	have_forkr��copy�deepcopy�environr��serverrrJr>rr:rrrIr�rSrWrB�base64�binasciirXr��decodebytes�decode�Error�UnicodeError�get_content_type�get_allr�r_�
setdefaultr�r4r�r�r�r�rorpr��waitpid�selectrQ�read�waitstatus_to_exitcoderr�setuidr)�dup2r+�execve�handle_error�request�_exit�
subprocessr�r�r r��list2cmdlinerFr2rD�Popen�PIPE�_sock�recv�communicater�r�r7r��
returncode))r�dir�restrL�i�nextdir�nextrest�	scriptdirrqrx�script�
scriptname�
scriptfile�ispyr��uqrestr�r�r��lengthr�r��ua�co�
cookie_str�k�
decoded_queryr�r��pid�sts�exitcoder��cmdline�interp�nbytes�p�datar�r��statuss)                                         rr�zCGIHTTPRequestHandler.run_cgis;��#��M�M�	��T��S�y�4����I�I�c�3�s�8�A�:�&���1�f��2�A�h�G��A�a�C�D�z�H��+�+�G�4�I��w�w�}�}�Y�'�#�X�T���I�I�c�3�s�8�A�:�.����1�f�����,���a��
�I�I�c�N����6����8�T�!�"�X�D�F���D�F��3�Y��'�
��(�(��4�
��w�w�~�~�j�)��O�O��$�$�)�J�6�
8�
��w�w�~�~�j�)��O�O��$�$�5�
�B�
D�
��~�~�j�)���>�>���%�%�j�1�����(�(�7�*�D�F���m�m�B�J�J�'��!%�!4�!4�!6����!�[�[�4�4��M��#,��� �!%�!6�!6���� ����!8�!8�9��M�� $���������%�%�d�+��!��K��!%�!4�!4�V�!<����'��M��#��N��!�0�0��3��M�����(�(��9�
��)�/�/�1�M��=�!�Q�&�'�#0��#3��K� � ��#�)�)�+�w�6�	B�(5�a�(8�(?�(?��(H�
�(.�(:�(:�=�(I�(.��w��&�
)6�(;�(;�C�(@�
��}�-��2�1>�q�1A�C�
�.��<�<���N�+�3�"&�,�,�"?�"?�"A�C���"&�,�,�~�">�C������!�!�"2�3���$*�C� �!��,�,�"�"�9�-���")�C������%�%�h��3�� �X�X�f�-��M��
�\�\�
�
�l�
+��
�%'�C�!�"�
�D�$�,�,�.�.�x��<�
=���Y�Y�r�]�
��!+�C�
��D�A��N�N�1�b�!�D�	
���:�=�=�*A�B������
�
�c�3�/�
��>�>��8�D��-�'����M�*��\�F��J�J�����'�'�)�C��a�x��:�:�c�1�-���S��m�m�T�Z�Z�L�"�b�!�<�Q�?��:�:�?�?�1�-���m�m�T�Z�Z�L�"�b�!�<�Q�?��4�4�S�9����N�N�%:�8�*�#E�F��

���I�I�f�%�����
�
�)�)�+�Q�/�����
�
�)�)�+�Q�/��	�	�*�d�C�0�
�!�l�G��~�~�j�)������<�<�>�*�*�7�3�#�C�R�[�6�"�#�;�6�F�!�4�.�7�2���%�����u�%����]�J�,C�,C�G�,L�M�
��V���� � ��'1���(2���(2���'*�	!�#�A��|�|�!�!�#�v�-�&�1�*��z�z���v�.�����-�-����!1�!1� 2�B��A�>�q�A��z�z�'�'�,�,�Q�/���-�-����!1�!1� 2�B��A�>�q�A��]�]�4�0�N�F�F��J�J���V�$�����t�V�,�
�H�H�N�N��
�H�H�N�N���\�\�F�����;�V�D�� � �!7�8��_%�N�N�L�9�����z�����

����(�(����t�7J�7J�K�����
��"�z�*�
���
�sP�4c�c'�A3c7�e�c$�#c$�'	c4�0c7�3c4�4c7�7Ae�e�eN)rrrrlrr��rbufsizer�rr�r�r�r�r�rrrrr�sG�����F�#�I��H�0�<��4"�8�,�O� �/�
x9rrc��tj|tjtjd��}t	t|��\}}}}}||fS)N)�type�flags)r�getaddrinfo�SOCK_STREAM�
AI_PASSIVE�next�iter)�address�infos�familyr�proto�	canonname�sockaddrs       r�_get_best_familyr�sM�����	�
�
�
����
�E�
04�D��K�/@�,�F�D�%��H��8��rr�i@c��	t||�\|_}||_|||�5}|jj	�dd\}}d|vrd|�d�n|}td|�d|�d|�d|�d�	�	|j
�ddd�y#t$r#td	�tjd
�Y�4wxYw#1swYyxYw)Nrr��[�]zServing HTTP on z port z	 (http://z/) ...z&
Keyboard interrupt received, exiting.r)
r�address_familyrJr�getsockname�print�
serve_forever�KeyboardInterruptr��exit)	�HandlerClass�ServerClass�protocolr�bind�addr�httpdr�url_hosts	         r�testr �s����
(8��d�'C�$�K���$,�L�!�	�T�<�	(�E��\�\�-�-�/���3�
��d�"%��+�Q�t�f�A�;�4��
��t�f�F�4�&�1��j��$��v�
/�	
�	����!�
)�	(��!�	��;�<��H�H�Q�K�	��
)�	(�s*�AB4�,B�)B1�.B4�0B1�1B4�4B=�__main__z--cgi�
store_truezrun as CGI server)�action�helpz-bz--bind�ADDRESSz.bind to this address (default: all interfaces))�metavarr$z-dz--directoryz1serve this directory (default: current directory))�defaultr$z-pz
--protocol�VERSIONz3conform to this HTTP version (default: %(default)s))r&r'r$rr[z(bind to this port (default: %(default)s))r'r�nargsr$c�$��eZdZ�fd�Zd�Z�xZS)�DualStackServerc����tjt�5|jj	tj
tjd�ddd�t�|�!�S#1swY�xYwr�)	�
contextlib�suppress�	Exceptionr�
setsockopt�IPPROTO_IPV6�IPV6_V6ONLYrr)rr	s �rrzDualStackServer.server_bindsU����$�$�Y�/����&�&��'�'��);�);�Q�@�0��7�&�(�(�0�/�s�:A+�+A4c�J�|j|||tj��y)Nr)�RequestHandlerClassr�r)rr�r�s   r�finish_requestzDualStackServer.finish_requests"���$�$�W�n�d�/3�~�~�
%�
?r)rrrrr5rsrts@rr+r+s
���	)�	?rr+)rrrrr)7r��__all__r�r-�email.utilsr�r��http.clientrNrMr�rmrr]r�rfrr
r�r��urllib.parserrr�r�rr�ThreadingMixInr�StreamRequestHandlerrrrr�r�r�rrr r�argparser-�ArgumentParser�parser�add_argumentrrF�
parse_argsr��cgi�
handler_classr+rrrrrr�<module>rCs
���d����
�����	���	��
�
�
��
������ 7��	 ��'�'�	 ��,�5�5�z��q�\�>�>�q�hA*�5�A*�L,�`
��
� $�
C9�4�C9�L�-�(��4�d��.�z����
$�X�
$�
$�
&�F�
�����0��2�
����h�	�9��:�����m�Y�R�Y�Y�[�<��=�����l�I� *�6��7������3�c�6��7�����D��x�x�-�
�0�
�?�-�?�	�"�#�
�Y�Y�
�Y�Y�����Qr

?>