AlkantarClanX12

Your IP : 52.14.88.137


Current Path : /proc/self/root/usr/lib64/python3.6/http/__pycache__/
Upload File :
Current File : //proc/self/root/usr/lib64/python3.6/http/__pycache__/server.cpython-36.opt-2.pyc

3

��f���@s�dZddddgZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlmZdZd	ZGd
d�dej�ZGdd�dej�ZGdd�de�Zd
d�Zdadd�Zdd�Z Gdd�de�Z!eedddfdd�Z"e#dk�r�ej$�Z%e%j&dddd�e%j&dddd d!d"�e%j&d#d$de'd%d&d'�e%j(�Z)e)j*�rze!Z+neZ+e"e+e)j,e)j-d(�dS))z0.6�
HTTPServer�BaseHTTPRequestHandler�SimpleHTTPRequestHandler�CGIHTTPRequestHandler�N)�
HTTPStatusa�<!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@seZdZdZdd�ZdS)r�cCs4tjj|�|jdd�\}}tj|�|_||_dS)N�)�socketserver�	TCPServer�server_bind�server_address�socketZgetfqdn�server_name�server_port)�self�host�port�r�#/usr/lib64/python3.6/http/server.pyr�szHTTPServer.server_bindN)�__name__�
__module__�__qualname__Zallow_reuse_addressrrrrrr�sc
@seZdZdejj�dZdeZe	Z
eZdZ
dd�Zdd�Zd	d
�Zdd�Zd?dd�Zd@dd�ZdAdd�Zdd�Zdd�Zdd�ZdBdd�Zdd�Zdd �Zd!d"�ZdCd#d$�Zd%d&�Zd'd(d)d*d+d,d-gZd
d.d/d0d1d2d3d4d5d6d7d8d9g
Zd:d;�Z d<Z!e"j#j$Z%d=d>�e&j'j(�D�Z)d
S)DrzPython/rz	BaseHTTP/zHTTP/0.9cCs�d|_|j|_}d|_t|jd�}|jd�}||_|j�}t	|�dk�r|\}}}yZ|dd�dkrjt
�|jdd�d}|jd	�}t	|�d
kr�t
�t|d�t|d�f}Wn*t
tfk
r�|j
tjd|�d
SX|dkr�|jdkr�d
|_|dk�rr|j
tjd|�d
Sn^t	|�d
k�rR|\}}d|_|dk�rr|j
tjd|�d
Sn |�s\d
S|j
tjd|�d
S||||_|_|_|jjd��r�d|jjd�|_ytjj|j|jd�|_Wnrtjjk
�r�}z|j
tjdt|��d
Sd}~Xn:tjjk
�r4}z|j
tjdt|��d
Sd}~XnX|jjdd�}	|	j�dk�rZd|_n |	j�dk�rz|jdk�rzd
|_|jjdd�}
|
j�dk�r�|jdk�r�|jdk�r�|j ��s�d
SdS)NTz
iso-8859-1z
��zHTTP/�/r�.rrzBad request version (%r)FzHTTP/1.1zInvalid HTTP version (%s)ZGETzBad HTTP/0.9 request type (%r)zBad request syntax (%r)z//)Z_classz
Line too longzToo many headers�
Connection��closez
keep-aliveZExpectz100-continue)rr)rr)!�command�default_request_version�request_version�close_connection�str�raw_requestline�rstrip�requestline�split�len�
ValueError�int�
IndexError�
send_errorrZBAD_REQUEST�protocol_versionZHTTP_VERSION_NOT_SUPPORTED�path�
startswith�lstrip�http�clientZ
parse_headers�rfile�MessageClass�headersZLineTooLongZREQUEST_HEADER_FIELDS_TOO_LARGEZ
HTTPException�get�lower�handle_expect_100)r�versionr&�wordsrr.Zbase_version_numberZversion_number�errZconntypeZexpectrrr�
parse_requests�












z$BaseHTTPRequestHandler.parse_requestcCs|jtj�|j�dS)NT)�send_response_onlyrZCONTINUE�end_headers)rrrrr8nsz(BaseHTTPRequestHandler.handle_expect_100cCs�y�|jjd�|_t|j�dkr@d|_d|_d|_|jtj	�dS|jsPd|_
dS|j�s\dSd|j}t||�s�|jtj
d|j�dSt||�}|�|jj�Wn4tjk
r�}z|jd|�d|_
dSd}~XnXdS)NiirTZdo_zUnsupported method (%r)zRequest timed out: %r)r3�readliner$r(r&r!rr,rZREQUEST_URI_TOO_LONGr"r<�hasattr�NOT_IMPLEMENTED�getattr�wfile�flushr
Ztimeout�	log_error)rZmname�method�errr�handle_one_request�s4


z)BaseHTTPRequestHandler.handle_one_requestcCs&d|_|j�x|js |j�qWdS)NT)r"rH)rrrr�handle�szBaseHTTPRequestHandler.handleNcCs
y|j|\}}Wntk
r.d\}}YnX|dkr<|}|dkrH|}|jd||�|j||�|jdd�d}|dkr�|tjtjtjfkr�|j	|t
j|dd�t
j|dd�d�}|jd	d
�}|jd|j
�|jdtt|���|j�|jd
ko�|�r|jj|�dS)N�???zcode %d, message %srr��F)�quote)�code�message�explainzUTF-8�replacezContent-TypezContent-LengthZHEAD)rJrJ)�	responses�KeyErrorrE�
send_response�send_headerrZ
NO_CONTENTZ
RESET_CONTENTZNOT_MODIFIED�error_message_format�html�escape�encode�error_content_typer#r(r>rrC�write)rrMrNrOZshortmsgZlongmsgZbodyZcontentrrrr,�s4
z!BaseHTTPRequestHandler.send_errorcCs:|j|�|j||�|jd|j��|jd|j��dS)NZServerZDate)�log_requestr=rT�version_string�date_time_string)rrMrNrrrrS�s
z$BaseHTTPRequestHandler.send_responsecCsd|jdkr`|dkr0||jkr,|j|d}nd}t|d�s@g|_|jjd|j||fjdd��dS)NzHTTP/0.9rr�_headers_bufferz
%s %d %s
zlatin-1�strict)r!rQr@r^�appendr-rX)rrMrNrrrr=�s


z)BaseHTTPRequestHandler.send_response_onlycCsl|jdkr6t|d�sg|_|jjd||fjdd��|j�dkrh|j�dkrVd|_n|j�d	krhd
|_dS)NzHTTP/0.9r^z%s: %s
zlatin-1r_Z
connectionrTz
keep-aliveF)r!r@r^r`rXr7r")r�keyword�valuerrrrT�s

z"BaseHTTPRequestHandler.send_headercCs"|jdkr|jjd�|j�dS)NzHTTP/0.9s
)r!r^r`�
flush_headers)rrrrr>s
z"BaseHTTPRequestHandler.end_headerscCs(t|d�r$|jjdj|j��g|_dS)Nr^�)r@rCrZ�joinr^)rrrrrcs
z$BaseHTTPRequestHandler.flush_headers�-cCs.t|t�r|j}|jd|jt|�t|��dS)Nz
"%s" %s %s)�
isinstancerrb�log_messager&r#)rrM�sizerrrr[s
z"BaseHTTPRequestHandler.log_requestcGs|j|f|��dS)N)rh)r�format�argsrrrrE!sz BaseHTTPRequestHandler.log_errorcGs&tjjd|j�|j�||f�dS)Nz%s - - [%s] %s
)�sys�stderrrZ�address_string�log_date_time_string)rrjrkrrrrh/sz"BaseHTTPRequestHandler.log_messagecCs|jd|jS)N� )�server_version�sys_version)rrrrr\Esz%BaseHTTPRequestHandler.version_stringcCs |dkrtj�}tjj|dd�S)NT)Zusegmt)�time�emailZutilsZ
formatdate)rZ	timestamprrrr]Isz'BaseHTTPRequestHandler.date_time_stringc	CsBtj�}tj|�\	}}}}}}}}	}
d||j|||||f}|S)Nz%02d/%3s/%04d %02d:%02d:%02d)rsZ	localtime�	monthname)rZnowZyearZmonthZdayZhhZmmZss�x�y�z�srrrroOs
z+BaseHTTPRequestHandler.log_date_time_stringZMonZTueZWedZThuZFriZSatZSunZJanZFebZMarZAprZMayZJunZJulZAugZSepZOctZNovZDeccCs
|jdS)Nr)�client_address)rrrrrn]sz%BaseHTTPRequestHandler.address_stringzHTTP/1.0cCsi|]}|j|jf|�qSr)�phraseZdescription)�.0�vrrr�
<dictcomp>lsz!BaseHTTPRequestHandler.<dictcomp>)NN)N)N)rfrf)N)*rrrrlr9r'rr�__version__rq�DEFAULT_ERROR_MESSAGErU�DEFAULT_ERROR_CONTENT_TYPErYr r<r8rHrIr,rSr=rTr>rcr[rErhr\r]roZweekdaynamerurnr-r1r2ZHTTPMessager4r�__members__�valuesrQrrrrr�s<ig%
5



	c@sxeZdZdeZdd�Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zej
sVej�ejj�Zejddddd��dS)rzSimpleHTTP/c
Cs.|j�}|r*z|j||j�Wd|j�XdS)N)�	send_head�copyfilerCr)r�frrr�do_GET�s
zSimpleHTTPRequestHandler.do_GETcCs|j�}|r|j�dS)N)r�r)rr�rrr�do_HEAD�sz SimpleHTTPRequestHandler.do_HEADc	Csx|j|j�}d}tjj|�r�tjj|j�}|jjd�s�|jt	j
�|d|d|dd|d|df}tjj|�}|jd|�|j
�dSx6dD]$}tjj||�}tjj|�r�|}Pq�W|j|�S|j|�}yt|d
�}Wn$tk
�r|jt	jd�dSXyZ|jt	j�|jd|�tj|j��}|jd
t|d��|jd|j|j��|j
�|S|j��YnXdS)Nrrrrr�ZLocation�
index.html�	index.htm�rbzFile not foundzContent-typezContent-Length�z
Last-Modified)r�r�)�translate_pathr.�os�isdir�urllib�parseZurlsplit�endswithrSrZMOVED_PERMANENTLYZ
urlunsplitrTr>re�exists�list_directory�
guess_type�open�OSErrorr,�	NOT_FOUND�OK�fstat�filenor#r]�st_mtimer)	rr.r��partsZ	new_partsZnew_url�indexZctypeZfsrrrr��sF


z"SimpleHTTPRequestHandler.send_headc
Cs�ytj|�}Wn"tk
r0|jtjd�dSX|jdd�d�g}ytjj	|j
dd�}Wn tk
r|tjj	|�}YnXtj
|dd�}tj�}d	|}|jd
�|jd�|jd|�|jd
|�|jd|�|jd�x~|D]v}tj
j||�}|}	}
tj
j|��r"|d}	|d}
tj
j|��r8|d}	|jdtjj|
dd�tj
|	dd�f�q�W|jd�dj|�j|d�}tj�}|j|�|jd�|jtj�|jdd|�|jdtt|���|j�|S)NzNo permission to list directorycSs|j�S)N)r7)�arrr�<lambda>�sz9SimpleHTTPRequestHandler.list_directory.<locals>.<lambda>)�key�
surrogatepass)�errorsF)rLzDirectory 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>r�@z<li><a href="%s">%s</a></li>z</ul>
<hr>
</body>
</html>
�
�surrogateescaperzContent-typeztext/html; charset=%szContent-Length) r��listdirr�r,rr��sortr�r��unquoter.�UnicodeDecodeErrorrVrWrl�getfilesystemencodingr`rer��islinkrLrX�io�BytesIOrZ�seekrSr�rTr#r(r>)
rr.�list�rZdisplaypath�enc�title�name�fullnameZdisplaynameZlinknameZencodedr�rrrr��s\







z'SimpleHTTPRequestHandler.list_directorycCs�|jdd�d}|jdd�d}|j�jd�}ytjj|dd�}Wn tk
rbtjj|�}YnXtj|�}|jd�}t	d|�}t
j�}x8|D]0}t
jj
|�s�|t
jt
jfkr�q�t
jj||�}q�W|r�|d7}|S)N�?rr�#rr�)r�)r'r%r�r�r�r�r��	posixpath�normpath�filterr��getcwdr.�dirname�curdir�pardirre)rr.Ztrailing_slashr:Zwordrrrr��s$	



z'SimpleHTTPRequestHandler.translate_pathcCstj||�dS)N)�shutilZcopyfileobj)r�sourceZ
outputfilerrrr�sz!SimpleHTTPRequestHandler.copyfilecCsLtj|�\}}||jkr"|j|S|j�}||jkr>|j|S|jdSdS)Nr)r��splitext�extensions_mapr7)rr.�baseZextrrrr�)s



z#SimpleHTTPRequestHandler.guess_typezapplication/octet-streamz
text/plain)rz.pyz.cz.hN)rrrrrqr�r�r�r�r�r�r��	mimetypesZinitedZinitZ	types_map�copyr��updaterrrrrrs 
	1:
c	Cs�|jd�\}}}tjj|�}|jd�}g}x<|dd�D],}|dkrN|j�q8|r8|dkr8|j|�q8W|r�|j�}|r�|dkr�|j�d}q�|dkr�d}nd}|r�dj||f�}ddj|�|f}dj|�}|S)Nr�rrz..rr���)�	partitionr�r�r�r'�popr`re)	r.�_�query�
path_partsZ
head_parts�partZ	tail_partZ	splitpath�collapsed_pathrrr�_url_collapse_pathNs.


r�cCsptrtSyddl}Wntk
r(dSXy|jd�daWn.tk
rjdtdd�|j�D��aYnXtS)Nrr�nobodyrcss|]}|dVqdS)rNr)r|rvrrr�	<genexpr>�sznobody_uid.<locals>.<genexpr>r�)r��pwd�ImportError�getpwnamrR�maxZgetpwall)r�rrr�
nobody_uid�s r�cCstj|tj�S)N)r��access�X_OK)r.rrr�
executable�sr�c@sReZdZeed�ZdZdd�Zdd�Zdd�Z	d	d
gZ
dd�Zd
d�Zdd�Z
dS)r�forkrcCs$|j�r|j�n|jtjd�dS)NzCan only POST to CGI scripts)�is_cgi�run_cgir,rrA)rrrr�do_POST�s

zCGIHTTPRequestHandler.do_POSTcCs|j�r|j�Stj|�SdS)N)r�r�rr�)rrrrr��szCGIHTTPRequestHandler.send_headcCsPt|j�}|jdd�}|d|�||dd�}}||jkrL||f|_dSdS)NrrTF)r�r.�find�cgi_directories�cgi_info)rr�Zdir_sep�head�tailrrrr��s


zCGIHTTPRequestHandler.is_cgiz/cgi-binz/htbincCst|�S)N)r�)rr.rrr�
is_executable�sz#CGIHTTPRequestHandler.is_executablecCstjj|�\}}|j�dkS)N�.py�.pyw)r�r�)r�r.r�r7)rr.r�r�rrr�	is_python�szCGIHTTPRequestHandler.is_pythonc)Cs�|j\}}|d|}|jdt|�d�}x`|dkr�|d|�}||dd�}|j|�}tjj|�r�||}}|jdt|�d�}q,Pq,W|jd�\}}}	|jd�}|dkr�|d|�||d�}
}n
|d}
}|d|
}|j|�}tjj|��s|j	t
jd|�dStjj|��s2|j	t
j
d|�dS|j|�}
|j�sL|
�rn|j|��sn|j	t
j
d|�dStjtj�}|j�|d	<|jj|d
<d|d<|j|d
<t|jj�|d<|j|d<tjj|�}||d<|j|�|d<||d<|	�r�|	|d<|jd|d<|jj d�}|�r�|j!�}t|�dk�r�ddl"}ddl#}|d|d<|dj$�dk�r�y"|dj%d�}|j&|�j'd�}Wn|j(t)fk
�r�Yn&X|j!d�}t|�dk�r�|d|d<|jj d�dk�r�|jj*�|d<n|jd|d<|jj d�}|�r||d<|jj d �}|�r"||d!<g}xN|jj+d"�D]>}|dd�d#k�rZ|j,|j-��n||d$d�j!d%�}�q4Wd%j.|�|d&<|jj d'�}|�r�||d(<t/d|jj0d)g��}d*j.|�}|�r�||d+<xd<D]}|j1|d��q�W|j2t
j3d-�|j4�|	j5d.d/�}|j�r.|
g}d0|k�r*|j,|�t6�}|j7j8�tj9�}|dk�r�tj:|d�\}}x0t;j;|j<gggd�d�r�|j<j=d��s^P�q^W|�r�|j>d1|�dSy\ytj?|�Wnt@k
�r�YnXtjA|j<jB�d�tjA|j7jB�d�tjC|||�Wn(|jjD|jE|j�tjFd2�YnX�n�ddlG} |g}!|j|��r�tHjI}"|"j$�jJd3��rv|"dd=�|"d>d�}"|"d6g|!}!d0|	k�r�|!j,|	�|jKd7| jL|!��ytM|�}#WntNtOfk
�r�d}#YnX| jP|!| jQ| jQ| jQ|d8�}$|jj$�d9k�r|#dk�r|j<j=|#�}%nd}%x4t;j;|j<jRgggd�d�rN|j<jRjSd��sP�qW|$jT|%�\}&}'|j7jU|&�|'�r||j>d:|'�|$jVjW�|$jXjW�|$jY}(|(�r�|j>d1|(�n
|jKd;�dS)?Nrrrr�rzNo such CGI script (%r)z#CGI script is not a plain file (%r)z!CGI script is not executable (%r)ZSERVER_SOFTWAREZSERVER_NAMEzCGI/1.1ZGATEWAY_INTERFACEZSERVER_PROTOCOLZSERVER_PORTZREQUEST_METHODZ	PATH_INFOZPATH_TRANSLATEDZSCRIPT_NAME�QUERY_STRINGZREMOTE_ADDR�
authorizationrZ	AUTH_TYPEZbasic�ascii�:ZREMOTE_USERzcontent-typeZCONTENT_TYPEzcontent-length�CONTENT_LENGTH�referer�HTTP_REFERER�acceptz	

 ��,ZHTTP_ACCEPTz
user-agent�HTTP_USER_AGENTZcookiez, �HTTP_COOKIE�REMOTE_HOSTzScript output follows�+rp�=zCGI script exit status %#x�zw.exerr�z-uzcommand: %s)�stdin�stdoutrm�envZpostz%szCGI script exited OK)r�r�r�r�r�r�������)Zr�r�r(r�r�r.r�r�r�r,rr��isfileZ	FORBIDDENr��	have_forkr�r��deepcopy�environr\Zserverrr-r#rrr�r�r�rzr5r6r'�base64�binasciir7rXZdecodebytes�decode�Error�UnicodeErrorZget_content_typeZgetallmatchingheadersr`�striprer�Zget_all�
setdefaultrSr�rcrPr�rCrDr��waitpid�selectr3�readrE�setuidr��dup2r��execveZhandle_errorZrequest�_exit�
subprocessrlr�r�rhZlist2cmdliner*�	TypeErrorr)�Popen�PIPEZ_sockZrecvZcommunicaterZrmrr��
returncode))r�dir�restr.�iZnextdirZnextrestZ	scriptdirr�r�ZscriptZ
scriptnameZ
scriptfileZispyr�Zuqrestr�rrZlengthr�r��lineZua�coZ
cookie_str�kZ
decoded_queryrkr��pid�stsrZcmdlineZinterp�nbytes�p�datar�rmZstatusrrrr��s4

























zCGIHTTPRequestHandler.run_cgiN)rrrr@r�r�Zrbufsizer�r�r�r�r�r�r�rrrrr�s
zHTTP/1.0i@rc	Cs�||f}||_|||��b}|jj�}d}t|j|d|dd��y|j�Wn&tk
rttd�tjd�YnXWdQRXdS)Nz>Serving HTTP on {host} port {port} (http://{host}:{port}/) ...rr)rrz&
Keyboard interrupt received, exiting.)	r-r
Zgetsockname�printrjZ
serve_forever�KeyboardInterruptrl�exit)	�HandlerClassZServerClassZprotocolr�bindrZhttpdZsaZ
serve_messagerrr�test�s
r$�__main__z--cgi�
store_truezRun as CGI Server)�action�helpz--bindz-bZADDRESSz8Specify alternate bind address [default: all interfaces])�default�metavarr(rZstorer�z&Specify alternate port [default: 8000])r'r)�type�nargsr()r"rr#).r�__all__Zemail.utilsrtrVZhttp.clientr1r�r�r�r�r	r�r
r	rlrsZurllib.parser�r��argparserr�r�r
rZStreamRequestHandlerrrr�r�r�r�rr$r�ArgumentParser�parser�add_argumentr*�
parse_argsrkZcgiZ
handler_classrr#rrrr�<module>Sshg]0