ok

Mini Shell

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

3

��d���@s\ddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddddddd	d
ddd
dddddddgZdZdZ
dZdZdZdZe�jejj�dd�ejjj�D�ZdZdZdZejd �jZejd!�jZejd"�Z d#d$d%hZ!d?d'd(�Z"Gd)d*�d*ej#j$�Z%e%fd+d,�Z&Gd-d�dej'�Z(Gd.d�d�Z)yddl*Z*Wne+k
�rVYnXGd/d0�d0e)�Z,ej-d0�Gd1d�de.�Z/Gd2d�de/�Z0Gd3d�de/�Z1Gd4d�de/�Z2Gd5d�de/�Z3Gd6d	�d	e/�Z4Gd7d
�d
e/�Z5Gd8d�de/�Z6Gd9d
�d
e6�Z7Gd:d�de6�Z8Gd;d�de6�Z9Gd<d�de/�Z:Gd=d�de/�Z;Gd>d�de<e:�Z=e/Z>dS)@�N)�urlsplit�HTTPResponse�HTTPConnection�
HTTPException�NotConnected�UnknownProtocol�UnknownTransferEncoding�UnimplementedFileMode�IncompleteRead�
InvalidURL�ImproperConnectionState�CannotSendRequest�CannotSendHeader�ResponseNotReady�
BadStatusLine�LineTooLong�RemoteDisconnected�error�	responses�Pi�ZUNKNOWNZIdlezRequest-startedzRequest-sentcCsi|]}|j|�qS�)�phrase)�.0�vrr�#/usr/lib64/python3.6/http/client.py�
<dictcomp>ksrii�ds[^:\s][^:\r\n]*s\n(?![ \t])|\r(?![ \t\n])z[- ]ZPATCHZPOSTZPUT�datacCsfy
|jd�Stk
r`}z:t|j|j|j|jd|j�||j|j�|f�d�WYdd}~XnXdS)Nzlatin-1z`%s (%.20r) is not valid Latin-1. Use %s.encode('utf-8') if you want to send it encoded in UTF-8.)�encode�UnicodeEncodeError�encoding�object�start�end�title)r�name�errrrr�_encode�s
r'c@seZdZdd�ZdS)�HTTPMessagecCsn|j�d}t|�}g}d}xL|j�D]@}|d|�j�|krDd}n|dd�j�sXd}|r&|j|�q&W|S)N�:r�)�lower�len�keys�isspace�append)�selfr%�nZlstZhit�linerrr�getallmatchingheaders�s
z!HTTPMessage.getallmatchingheadersN)�__name__�
__module__�__qualname__r3rrrrr(�sr(cCs|g}xR|jtd�}t|�tkr(td��|j|�t|�tkrJtdt��|d	krPqWdj|�jd�}t	j
j|d�j|�S)
Nr*zheader linezgot more than %d headers�
�
�z
iso-8859-1)�_class)r7r8r9)
�readline�_MAXLINEr,rr/�_MAXHEADERSr�join�decode�email�parserZParserZparsestr)�fpr:�headersr2Zhstringrrr�
parse_headers�s

rDcseZdZd@dd�Zdd�Zdd�Zd	d
�Zdd�Z�fd
d�Z�fdd�Z	dd�Z
dd�ZdAdd�Zdd�Z
dd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�ZdCd(d)�ZdEd*d+�ZdG�fd,d-�	Zd.d/�Zd0d1�Zd2d3�ZdHd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Zd>d?�Z �Z!S)IrrNcCsR|jd�|_||_||_d|_|_t|_t|_t|_	t|_
t|_t|_t|_
dS)N�rb)�makefilerB�
debuglevel�_methodrC�msg�_UNKNOWN�version�status�reason�chunked�
chunk_left�length�
will_close)r0�sockrG�method�urlrrr�__init__�szHTTPResponse.__init__cCst|jjtd�d�}t|�tkr*td��|jdkrBtdt|��|sNt	d��y|j
dd�\}}}WnFtk
r�y|j
dd�\}}d}Wntk
r�d}YnXYnX|jd	�s�|j
�t|��y$t|�}|d
ks�|dkr�t|��Wntk
�rt|��YnX|||fS)Nr*z
iso-8859-1zstatus linerzreply:z-Remote end closed connection without response��zHTTP/ri�)�strrBr;r<r,rrG�print�reprr�split�
ValueError�
startswith�_close_connr�int)r0r2rKrLrMrrr�_read_statuss2

zHTTPResponse._read_statuscCs|jdk	rdSxh|j�\}}}|tkr(PxJ|jjtd�}t|�tkrNtd��|j�}|s\P|j	dkr*t
d|�q*WqW||_|_|j�|_
|dkr�d|_n|jd�r�d	|_nt|��t|j�|_|_|j	dk�r�x&|jD]}t
d|d
|jj|��q�W|jjd�}|�r,|j�dk�r,d
|_d|_nd|_|j�|_d|_|jjd�}|jjd�}|�r�|j�r�yt|�|_Wntk
�r�d|_YnX|jdk�r�d|_nd|_|tk�s�|tk�s�d|k�o�dkn�s�|jdk�r�d|_|j�r|j�r|jdk�rd
|_dS)Nr*zheader linerzheader:�HTTP/1.0�HTTP/0.9�
zHTTP/1.�r)ztransfer-encodingrNTFzcontent-lengthr���HEAD)rarb)rCr`ZCONTINUErBr;r<r,r�striprGrY�coderLrMrKr]rrDrI�getr+rNrO�_check_closerQrPr_r\Z
NO_CONTENTZNOT_MODIFIEDrH)r0rKrLrM�skip�hdrZtr_encrPrrr�begin,sf






zHTTPResponse.begincCs�|jjd�}|jdkr:|jjd�}|r6d|j�kr6dSdS|jjd�rJdS|r^d|j�kr^dS|jjd�}|r~d|j�kr~dSdS)NZ
connectionrd�closeTFz
keep-alivezproxy-connection)rCrirKr+)r0ZconnZpconnrrrrj|s
zHTTPResponse._check_closecCs|j}d|_|j�dS)N)rBrn)r0rBrrrr^�szHTTPResponse._close_connc
s$zt�j�Wd|jr|j�XdS)N)�superrnrBr^)r0)�	__class__rrrn�szHTTPResponse.closecst�j�|jr|jj�dS)N)ro�flushrB)r0)rprrrq�s
zHTTPResponse.flushcCsdS)NTr)r0rrr�readable�szHTTPResponse.readablecCs
|jdkS)N)rB)r0rrr�isclosed�szHTTPResponse.isclosedcCs�|jdkrdS|jdkr$|j�dS|dk	rRt|�}|j|�}t|�d|�j�S|jr`|j�S|j	dkrv|jj
�}n6y|j|j	�}Wntk
r�|j��YnXd|_	|j�|SdS)Nr9rfr)
rBrHr^�	bytearray�readinto�
memoryview�tobytesrN�_readall_chunkedrP�read�
_safe_readr
)r0�amt�br1�srrrry�s*



zHTTPResponse.readcCs�|jdkrdS|jdkr$|j�dS|jr4|j|�S|jdk	r^t|�|jkr^t|�d|j�}|jj|�}|r~|r~|j�n&|jdk	r�|j|8_|js�|j�|S)Nrrf)	rBrHr^rN�_readinto_chunkedrPr,rvru)r0r|r1rrrru�s$






zHTTPResponse.readintocCsp|jjtd�}t|�tkr$td��|jd�}|dkrB|d|�}y
t|d�Stk
rj|j��YnXdS)Nr*z
chunk size�;r�)	rBr;r<r,r�findr_r\r^)r0r2�irrr�_read_next_chunk_sizes

z"HTTPResponse._read_next_chunk_sizecCs>x8|jjtd�}t|�tkr&td��|s,P|dkrPqWdS)Nr*ztrailer line�
r8r9)r�r8r9)rBr;r<r,r)r0r2rrr�_read_and_discard_trailersz&HTTPResponse._read_and_discard_trailercCsl|j}|sh|dk	r|jd�y|j�}Wntk
rDtd��YnX|dkrb|j�|j�d}||_|S)NrVr9r)rOrzr�r\r
r�r^)r0rOrrr�_get_chunk_left s
zHTTPResponse._get_chunk_leftcCsdg}y8x,|j�}|dkrP|j|j|��d|_qWdj|�Stk
r^tdj|���YnXdS)Nrr9)r�r/rzrOr>r
)r0�valuerOrrrrx8s

zHTTPResponse._readall_chunkedcCs�d}t|�}yvxp|j�}|dkr$|St|�|krL|j|�}|||_||S|d|�}|j|�}||d�}||7}d|_qWWn(tk
r�tt|d|����YnXdS)Nr)rvr�r,�_safe_readintorOr
�bytes)r0r|�total_bytes�mvbrOr1�temp_mvbrrrr~Fs$


zHTTPResponse._readinto_chunkedcCsXg}xH|dkrL|jjt|t��}|s4tdj|�|��|j|�|t|�8}qWdj|�S)Nrr9)rBry�min�	MAXAMOUNTr
r>r/r,)r0r{r}�chunkrrrrz^s

zHTTPResponse._safe_readcCs�d}t|�}xt|t|�kr�tt|�kr@|dt�}|jj|�}n|jj|�}|sjtt|d|��t|���||d�}||7}qW|S)Nr)rvr,r�rBrur
r�)r0r|r�r�r�r1rrrr�uszHTTPResponse._safe_readintor*cCs�|jdks|jdkrdS|jr(|j|�S|jdk	rJ|dksD||jkrJ|j}y|jj|�}Wn*tk
r�|dkrt�|jjd�}YnX|r�|r�|j�n|jdk	r�|jt|�8_|S)Nrfr9rr�ii@)	rBrHrN�_read1_chunkedrP�read1r\r^r,)r0r1�resultrrrr��s"



zHTTPResponse.read1cCs4|jdks|jdkrdS|jr(|j|�S|jj|�S)Nrfr9)rBrHrN�
_peek_chunked�peek)r0r1rrrr��s

zHTTPResponse.peekcs�|jdks|jdkrdS|jr*t�j|�S|jdk	rL|dksF||jkrL|j}|jj|�}|rl|rl|j�n|jdk	r�|jt|�8_|S)Nrfr9r)rBrHrNror;rPr^r,)r0�limitr�)rprrr;�s


zHTTPResponse.readlinecCsf|j�}|dks|dkrdSd|ko.|kns8|}|jj|�}|jt|�8_|sbtd��|S)Nrr9)r�rBr�rOr,r
)r0r1rOryrrrr��szHTTPResponse._read1_chunkedcCsBy|j�}Wntk
r dSX|dkr.dS|jj|�d|�S)Nr9)r�r
rBr�)r0r1rOrrrr��szHTTPResponse._peek_chunkedcCs
|jj�S)N)rB�fileno)r0rrrr��szHTTPResponse.filenocCsH|jdkrt��|jj|�p|}t|t�s6t|d�r:|Sdj|�SdS)N�__iter__z, )rCrZget_all�
isinstancerX�hasattrr>)r0r%�defaultrCrrr�	getheader�s
zHTTPResponse.getheadercCs|jdkrt��t|jj��S)N)rCr�list�items)r0rrr�
getheaders�s
zHTTPResponse.getheaderscCs|S)Nr)r0rrrr��szHTTPResponse.__iter__cCs|jS)N)rC)r0rrr�info�szHTTPResponse.infocCs|jS)N)rT)r0rrr�geturls
zHTTPResponse.geturlcCs|jS)N)rL)r0rrr�getcodeszHTTPResponse.getcode)rNN)N���)r�r�)r�r�)r�)N)"r4r5r6rUr`rmrjr^rnrqrrrsryrur�r�r�rxr~rzr�r�r�r;r�r�r�r�r�r�r�r�r��
__classcell__rr)rprr�s<	
!P

 "

	

c@s�eZdZdZdZeZeZdZ	dZ
edd��Zedd��Z
d	ejd	fd
d�Zd.dd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd/dd �Zd0d!d"�Zd#d$�Zd1dd%�d&d'�Zd	ifdd%�d(d)�Zd*d+�Zd,d-�Z d	S)2rrdzHTTP/1.1r*rcCst|tj�S)N)r��io�
TextIOBase)�streamrrr�
_is_textIO(szHTTPConnection._is_textIOcCsd|dkr|j�tkrdSdSt|d�r*dSyt|�}|jStk
rLYnXt|t�r`t|�SdS)Nrry)	�upper�_METHODS_EXPECTING_BODYr�rv�nbytes�	TypeErrorr�rXr,)�bodyrSZmvrrr�_get_content_length.s

z"HTTPConnection._get_content_lengthNcCs\||_||_d|_g|_d|_t|_d|_d|_d|_	i|_
|j||�\|_|_
tj|_dS)N)�timeout�source_addressrR�_buffer�_HTTPConnection__response�_CS_IDLE�_HTTPConnection__staterH�_tunnel_host�_tunnel_port�_tunnel_headers�
_get_hostport�host�port�socketZcreate_connection�_create_connection)r0r�r�r�r�rrrrUNszHTTPConnection.__init__cCs<|jrtd��|j||�\|_|_|r.||_n
|jj�dS)Nz.Can't set up tunnel for established connection)rR�RuntimeErrorr�r�r�r��clear)r0r�r�rCrrr�
set_tunnelaszHTTPConnection.set_tunnelcCs�|dkr�|jd�}|jd�}||kr�yt||dd��}WnHtk
r�||dd�dkrh|j}ntd||dd���YnX|d|�}n|j}|r�|ddkr�|ddkr�|dd	�}||fS)
Nr)�]r*rWznonnumeric port: '%s'r�[r�r�)�rfindr_r\�default_portr)r0r�r�r��jrrrr�ys

zHTTPConnection._get_hostportcCs
||_dS)N)rG)r0�levelrrr�set_debuglevel�szHTTPConnection.set_debuglevelcCsd|j|jf}|jd�}|j|�x6|jj�D](\}}d||f}|jd�}|j|�q0W|jd�|j|j|jd�}|j	�\}}	}
|	t
jjkr�|j
�td|	|
j�f��xP|jjtd�}t|�tkr�td	��|s�P|dkr�P|jdkr�td
|j��q�WdS)NzCONNECT %s:%d HTTP/1.0
�asciiz%s: %s
zlatin-1�
)rSzTunnel connection failed: %d %sr*zheader liner8r9rzheader:)r�r8r9)r�r�r�sendr�r��response_classrRrHr`�http�
HTTPStatusZOKrn�OSErrorrgrBr;r<r,rrGrYr?)r0Zconnect_strZ
connect_bytes�headerr�Z
header_strZheader_bytes�responserKrh�messager2rrr�_tunnel�s2





zHTTPConnection._tunnelcCsB|j|j|jf|j|j�|_|jjtjtj	d�|j
r>|j�dS)Nr*)r�r�r�r�r�rRZ
setsockoptr�ZIPPROTO_TCPZTCP_NODELAYr�r�)r0rrr�connect�s
zHTTPConnection.connectcCsBt|_z|j}|r d|_|j�Wd|j}|r<d|_|j�XdS)N)r�r�rRrnr�)r0rRr�rrrrn�szHTTPConnection.closecCs|jdkr |jr|j�nt��|jdkr8tdt|��d}t|d�r�|jdkrXtd�|j|�}|rx|jdkrxtd�x.|j	|�}|s�P|r�|j
d�}|jj|�qzWdSy|jj|�WnNtk
�r
t
|tj�r�x*|D]}|jj|�q�Wntdt|���YnXdS)	Nrzsend:i ryzsendIng a read()ablezencoding file using iso-8859-1z
iso-8859-1z9data should be a bytes-like object or an iterable, got %r)rR�	auto_openr�rrGrYrZr�r�ryrZsendallr�r��collections�Iterable�type)r0r�	blocksizer�	datablock�drrrr��s:








zHTTPConnection.sendcCs|jj|�dS)N)r�r/)r0r}rrr�_output�szHTTPConnection._outputccsdd}|jdkrtd�|j|�}|r6|jdkr6td�x(|j|�}|sHP|rV|jd�}|Vq8WdS)Ni rzsendIng a read()ablezencoding file using iso-8859-1z
iso-8859-1)rGrYr�ryr)r0rrr�rr�rrr�_read_readable�s



zHTTPConnection._read_readableFcCs$|jjd�dj|j�}|jdd�=|j|�|dk	�r t|d�rN|j|�}nZyt|�WnFtk
r�yt|�}Wn$tk
r�tdt	|���YnXYnX|f}xZ|D]R}|s�|j
dkr�td�q�|r�|jdkr�t
|�d�d	�jd
�|d}|j|�q�W|�r |jdk�r |jd�dS)
Nr9s
ryzAmessage_body should be a bytes-like object or an iterable, got %rrzZero length chunk ignoredrd�Xz
r�s0

)r9r9)r��extendr>r�r�r�rvr��iterr�rGrY�	_http_vsnr,r)r0�message_body�encode_chunkedrIZchunksr�rrr�_send_outputs4




zHTTPConnection._send_outputc

Cs�|jr|jj�rd|_|jtkr(t|_n
t|j��||_|s@d}tj|�}|rht	d|�d|j
��d���d|||jf}|j|j
d��|jdk�r�|�s�d}|jd	�r�t|�\}}}}}|r�y|j
d�}	Wntk
r�|j
d
�}	YnX|jd|	�n�|j�r|j}
|j}n|j}
|j}y|
j
d�}Wn tk
�rJ|
j
d
�}YnX|
jd�d
k�rhd|d}||jk�r�|jd|�n|jd�}|jdd||f�|�s�|jdd�ndS)N�/z&URL can't contain control characters. z (found at least �)z%s %s %sr�rdrWr�ZidnaZHostr)r�[�]z%s:%szAccept-EncodingZidentity)r�rsr�r��_CS_REQ_STARTEDr
rH�!_contains_disallowed_url_pchar_re�searchr�group�
_http_vsn_strr�rr�r]rr�	putheaderr�r�r�r�r�r�r?)
r0rSrT�	skip_host�skip_accept_encoding�match�requestZnetlocZnilZ
netloc_encr�r�Zhost_encrrr�
putrequest9sT





zHTTPConnection.putrequestcGs�|jtkrt��t|d�r$|jd�}t|�s:td|f��t|�}xht|�D]\\}}t|d�rn|jd�||<nt	|t
�r�t|�jd�||<t||�rLtd||f��qLWdj
|�}|d|}|j|�dS)Nrr�zInvalid header name %rzlatin-1zInvalid header value %rs
	s: )r�r�rr�r�_is_legal_header_namer\r��	enumerater�r_rX�_is_illegal_header_valuer>r�)r0r��valuesr�Z	one_valuer�rrrr��s"





zHTTPConnection.putheader)r�cCs*|jtkrt|_nt��|j||d�dS)N)r�)r�r��_CS_REQ_SENTrr�)r0r�r�rrr�
endheaders�s
zHTTPConnection.endheaderscCs|j|||||�dS)N)�
_send_request)r0rSrTr�rCr�rrrr��szHTTPConnection.requestcCs�tdd�|D��}i}d|kr&d|d<d|kr6d|d<|j||f|�d|kr�d	|kr�d
}|j||�}|dkr�|dk	r�|jdkr�td|�d
}|jdd�q�|jdt|��nd
}x |j�D]\}	}
|j|	|
�q�Wt|t�r�t	|d�}|j
||d�dS)Ncss|]}|j�VqdS)N)r+)r�krrr�	<genexpr>�sz/HTTPConnection._send_request.<locals>.<genexpr>r�r*r�zaccept-encodingr�zcontent-lengthztransfer-encodingFrzUnable to determine size of %rTzTransfer-EncodingrNzContent-Lengthr�)r�)�	frozensetr�r�rGrYr�rXr�r�r'r�)r0rSrTr�rCr�Zheader_namesZskipsZcontent_lengthrlr�rrrr��s0	


zHTTPConnection._send_requestcCs�|jr|jj�rd|_|jtks&|jr0t|j��|jdkrR|j|j|j|jd�}n|j|j|jd�}yLy|j	�Wnt
k
r�|j��YnXt|_|j
r�|j�n||_|S|j��YnXdS)Nr)rS)r�rsr�r�rrGr�rRrHrm�ConnectionErrorrnr�rQ)r0r�rrr�getresponses,


zHTTPConnection.getresponse)NN)NF)FF)N)!r4r5r6r�r�rr��	HTTP_PORTr�r�rG�staticmethodr�r�r��_GLOBAL_DEFAULT_TIMEOUTrUr�r�r�r�r�rnr�r�r�r�r�r�r�r�r�r�rrrrrs: 
	'
6

.csBeZdZeZdddejdfddd��fdd�Z�fdd�Z�Z	S)�HTTPSConnectionN)�context�check_hostnamecs�tt|�j||||�|dk	s.|dk	s.|dk	rDddl}	|	jdtd�||_||_|dkr`tj	�}|j
tjk}
|dkrz|j}|r�|
r�t
d��|s�|r�|j||�||_||_dS)NrzTkey_file, cert_file and check_hostname are deprecated, use a custom context instead.rVzMcheck_hostname needs a SSL context with either CERT_OPTIONAL or CERT_REQUIRED)rorrU�warnings�warn�DeprecationWarning�key_file�	cert_file�sslZ_create_default_https_contextZverify_modeZ	CERT_NONErr\Zload_cert_chain�_context�_check_hostname)r0r�r�rrr�r�rrrZwill_verify)rprrrUas(
zHTTPSConnection.__init__cs�t�j�|jr|j}n|j}|jj|j|d�|_|jjr�|jr�yt	j
|jj�|�Wn.tk
r�|jj
tj�|jj��YnXdS)N)�server_hostname)ror�r�r�r	Zwrap_socketrRrr
rZmatch_hostnameZgetpeercert�	ExceptionZshutdownr�Z	SHUT_RDWRrn)r0r)rprrr�|s



zHTTPSConnection.connect)
r4r5r6�
HTTPS_PORTr�r�r�rUr�r�rr)rprrZsrc@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdd�ZdS)rcCs|f|_||_dS)N)�argsrK)r0rKrrrrU�szUnknownProtocol.__init__N)r4r5r6rUrrrrr�sc@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdS)r	N)r4r5r6rrrrr	�sc@s&eZdZddd�Zdd�Zdd�ZdS)	r
NcCs|f|_||_||_dS)N)r�partial�expected)r0rrrrrrU�szIncompleteRead.__init__cCs2|jdk	rd|j}nd}d|jjt|j�|fS)Nz, %i more expectedrWz%s(%i bytes read%s))rrpr4r,r)r0�errr�__repr__�s

zIncompleteRead.__repr__cCst|�S)N)rZ)r0rrr�__str__�szIncompleteRead.__str__)N)r4r5r6rUrrrrrrr
�s
c@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdS)r
N)r4r5r6rrrrr
�sc@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdS)rN)r4r5r6rrrrr�sc@seZdZdd�ZdS)rcCs|st|�}|f|_||_dS)N)rZrr2)r0r2rrrrU�szBadStatusLine.__init__N)r4r5r6rUrrrrr�sc@seZdZdd�ZdS)rcCstj|dt|f�dS)Nz&got more than %d bytes when reading %s)rrUr<)r0Z	line_typerrrrU�szLineTooLong.__init__N)r4r5r6rUrrrrr�sc@seZdZdd�ZdS)rcOs"tj|d�tj|f|�|�dS)NrW)rrU�ConnectionResetError)r0�pos�kwrrrrU�szRemoteDisconnected.__init__N)r4r5r6rUrrrrr�s)r)?Zemail.parserr@Z
email.messager�r��os�rer�r�Zurllib.parser�__all__r�r
rJr�r�r��globals�updater��__members__r�rr�r<r=�compile�	fullmatchr�r�r�r�r�r'r�ZMessager(rD�BufferedIOBaserrr�ImportErrorrr/rrrrrrr	r
rr
rrrrrrrrrrr�<module>Gs�


>;6


Zerion Mini Shell 1.0