Your IP : 18.118.186.156


Current Path : /opt/alt/python39/lib64/python3.9/http/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/http/__pycache__/client.cpython-39.opt-2.pyc

a

R�f���@sJddlZddlZddlZddlZddlZddlZddlZddlZ	ddl
mZgd�ZdZ
dZdZdZdZd	Ze��ejj�d
d�ejj��D�ZdZd
ZdZe�d�jZe�d�jZ e�d�Z!e�d�Z"hd�Z#d?dd�Z$Gdd�dej%j&�Z'dd�Z(e'fdd�Z)Gdd�dej*�Z+Gdd �d �Z,zddl-Z-Wne.�yDYn0Gd!d"�d"e,�Z/e�0d"�Gd#d$�d$e1�Z2Gd%d&�d&e2�Z3Gd'd(�d(e2�Z4Gd)d*�d*e2�Z5Gd+d,�d,e2�Z6Gd-d.�d.e2�Z7Gd/d0�d0e2�Z8Gd1d2�d2e2�Z9Gd3d4�d4e9�Z:Gd5d6�d6e9�Z;Gd7d8�d8e9�Z<Gd9d:�d:e2�Z=Gd;d<�d<e2�Z>Gd=d>�d>e?e=�Z@e2ZAdS)@�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�0/opt/alt/python39/lib64/python3.9/http/client.py�
<dictcomp>k�rii�ds[^:\s][^:\r\n]*s\n(?![ \t])|\r(?![ \t\n])z[- ]z[-]>ZPUTZPATCHZPOST�datac
Csjz|�d�WStyd}z@t|j|j|j|jd|��||j|j�|f�d�WYd}~n
d}~00dS)N�latin-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)�HTTPMessagecCsj|��d}t|�}g}d}|��D]@}|d|���|krBd}n|dd���sVd}|r$|�|�q$|S)N�:r�)�lower�len�keys�isspace�append)�selfr'�nZlstZhit�linerrr�getallmatchingheaders�s
z!HTTPMessage.getallmatchingheadersN)�__name__�
__module__�__qualname__r5rrrrr*�sr*cCsXg}|�td�}t|�tkr&td��|�|�t|�tkrHtdt��|dvrqTq|S)Nr,�header linezgot more than %d headers��
�
r)�readline�_MAXLINEr.rr1�_MAXHEADERSr)�fp�headersr4rrr�
_read_headers�s
rBcCs,t|�}d�|��d�}tjj|d��|�S)Nr�
iso-8859-1)�_class)rB�join�decode�email�parserZParserZparsestr)r@rDrAZhstringrrr�
parse_headers�s
rIcseZdZd@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&�ZdBd(d)�ZdCd*d+�ZdD�fd,d-�	Zd.d/�Zd0d1�Zd2d3�ZdEd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Zd>d?�Z �Z!S)FrrNcCsR|�d�|_||_||_d|_|_t|_t|_t|_	t|_
t|_t|_t|_
dS)N�rb)Zmakefiler@�
debuglevel�_methodrA�msg�_UNKNOWN�version�status�reason�chunked�
chunk_left�length�
will_close)r2�sockrK�method�urlrrr�__init__�szHTTPResponse.__init__cCst|j�td�d�}t|�tkr*td��|jdkrBtdt|��|sNt	d��z|�
dd�\}}}WnBty�z|�
dd�\}}d}Wnty�d}Yn0Yn0|�d	�s�|�
�t|��z$t|�}|d
ks�|dkr�t|��Wnt�yt|��Yn0|||fS)Nr,rCzstatus linerzreply:z-Remote end closed connection without response��zHTTP/ri�)�strr@r=r>r.rrK�print�reprr�split�
ValueError�
startswith�_close_connr�int)r2r4rOrPrQrrr�_read_statuss2

zHTTPResponse._read_statusc	Cs�|jdurdS|��\}}}|tkr&qHt|j�}|jdkrDtd|�~q||_|_|�	�|_
|dvrnd|_n|�d�r�d|_nt
|��t|j�|_|_|jdkr�|j��D]\}}td|d|�q�|j�d	�}|r�|��d
kr�d|_d|_nd|_|��|_d|_|j�d
�}|�r`|j�s`zt|�|_Wnt�yJd|_Yn0|jdk�rfd|_nd|_|tk�s�|tk�s�d|k�r�dk�s�n|jdk�r�d|_|j�s�|j�s�|jdu�r�d|_dS)Nrzheaders:)zHTTP/1.0zHTTP/0.9�
zHTTP/1.��header:r+�transfer-encodingrRTF�content-lengthr���HEAD)rArdZCONTINUErBr@rKr]�coderP�striprQrOrarrIrM�items�getr-rRrS�_check_closerUrTrcr`Z
NO_CONTENTZNOT_MODIFIEDrL)	r2rOrPrQZskipped_headers�hdr�valZtr_encrTrrr�begin9sd







�
�
���zHTTPResponse.begincCsv|j�d�}|jdkr.|r*d|��vr*dSdS|j�d�r>dS|rRd|��vrRdS|j�d�}|rrd|��vrrdSdS)NZ
connectionrf�closeTFz
keep-alivezproxy-connection)rArorOr-)r2ZconnZpconnrrrrp�s
zHTTPResponse._check_closecCs|j}d|_|��dS�N)r@rt)r2r@rrrrb�szHTTPResponse._close_conncs2zt���W|jr.|��n|jr,|��0dSru)�superrtr@rb�r2��	__class__rrrt�s
�zHTTPResponse.closecst���|jr|j��dSru)rv�flushr@rwrxrrrz�s
zHTTPResponse.flushcCsdS)NTrrwrrr�readable�szHTTPResponse.readablecCs
|jduSru)r@rwrrr�isclosed�szHTTPResponse.isclosedcCs�|jdurdS|jdkr$|��dS|durRt|�}|�|�}t|�d|���S|jr`|��S|j	durv|j�
�}n4z|�|j	�}Wnty�|���Yn0d|_	|��|SdS)Nrrkr)
r@rLrb�	bytearray�readinto�
memoryview�tobytesrR�_readall_chunkedrT�read�
_safe_readr
)r2�amt�br3�srrrr��s*



zHTTPResponse.readcCs�|jdurdS|jdkr$|��dS|jr4|�|�S|jdur^t|�|jkr^t|�d|j�}|j�|�}|s||r||��n&|jdur�|j|8_|js�|��|S)Nrrk)	r@rLrbrR�_readinto_chunkedrTr.rr~)r2r�r3rrrr~�s$





zHTTPResponse.readintocCsp|j�td�}t|�tkr$td��|�d�}|dkrB|d|�}zt|d�WStyj|���Yn0dS)Nr,z
chunk size�;r�)	r@r=r>r.r�findrcr`rb)r2r4�irrr�_read_next_chunk_sizes
z"HTTPResponse._read_next_chunk_sizecCs:|j�td�}t|�tkr$td��|s*q6|dvrq6qdS)Nr,ztrailer liner:)r@r=r>r.r�r2r4rrr�_read_and_discard_trailersz&HTTPResponse._read_and_discard_trailercCsj|j}|sf|dur|�d�z|��}WntyBtd��Yn0|dkr`|��|��d}||_|S)NrZrr)rSr�r�r`r
r�rb)r2rSrrr�_get_chunk_left$s
zHTTPResponse._get_chunk_leftcCs`g}z6|��}|durq0|�|�|��d|_qd�|�WStyZtd�|���Yn0dS�Nrr)r�r1r�rSrEr
)r2�valuerSrrrr�<szHTTPResponse._readall_chunkedcCs�d}t|�}zv|��}|dur$|WSt|�|krN|�|�}|||_||WS|d|�}|�|�}||d�}||7}d|_qWn&ty�tt|d|����Yn0dS�Nr)rr�r.�_safe_readintorSr
�bytes)r2r��total_bytes�mvbrSr3�temp_mvbrrrr�Js"



zHTTPResponse._readinto_chunkedcCsTg}|dkrJ|j�t|t��}|s2td�|�|��|�|�|t|�8}qd�|�Sr�)r@r��min�	MAXAMOUNTr
rEr1r.)r2r�r��chunkrrrr�bs
zHTTPResponse._safe_readcCs�d}t|�}|t|�kr~tt|�kr>|dt�}|j�|�}n|j�|�}|shtt|d|��t|���||d�}||7}q|Sr�)rr.r�r@r~r
r�)r2r�r�r�r�r3rrrr�ys
zHTTPResponse._safe_readinto���cCs�|jdus|jdkrdS|jr(|�|�S|jdurJ|dksD||jkrJ|j}|j�|�}|sh|rh|��n|jdur�|jt|�8_|S�Nrkrr)r@rLrR�_read1_chunkedrT�read1rbr.)r2r3�resultrrrr��s


zHTTPResponse.read1cCs4|jdus|jdkrdS|jr(|�|�S|j�|�S)Nrkr)r@rLrR�
_peek_chunked�peek)r2r3rrrr��s

zHTTPResponse.peekcs�|jdus|jdkrdS|jr*t��|�S|jdurL|dksF||jkrL|j}|j�|�}|sj|rj|��n|jdur�|jt|�8_|Sr�)r@rLrRrvr=rTrbr.)r2�limitr�rxrrr=�s

zHTTPResponse.readlinecCsd|��}|dus|dkrdSd|kr0|ks6n|}|j�|�}|jt|�8_|s`td��|Sr�)r�r@r�rSr.r
)r2r3rSr�rrrr��szHTTPResponse._read1_chunkedcCsBz|��}Wnty YdS0|dur.dS|j�|�d|�S)Nr)r�r
r@r�)r2r3rSrrrr��szHTTPResponse._peek_chunkedcCs
|j��Sru)r@�filenorwrrrr��szHTTPResponse.filenocCsF|jdurt��|j�|�p|}t|t�s4t|d�s8|Sd�|�SdS)N�__iter__z, )rArZget_all�
isinstancer\�hasattrrE)r2r'�defaultrArrr�	getheader�s
zHTTPResponse.getheadercCs|jdurt��t|j���Sru)rAr�listrnrwrrr�
getheaders�s
zHTTPResponse.getheaderscCs|Srurrwrrrr��szHTTPResponse.__iter__cCs|jSru)rArwrrr�info�szHTTPResponse.infocCs|jSru)rXrwrrr�geturls
zHTTPResponse.geturlcCs|jSru)rPrwrrr�getcodeszHTTPResponse.getcode)rNN)N)r�)r�)r�)N)"r6r7r8rYrdrsrprbrtrzr{r|r�r~r�r�r�r�r�r�r�r�r�r=r�r�r�r�r�r�r�r�r��
__classcell__rrrxrr�s<	
!H

 "

	

rc@s
eZdZdZdZeZeZdZ	dZ
edd��Zedd��Z
d	ejd	d
fdd�Zd7d
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd8d d!�Zd9d"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Z d:dd.�d/d0�Z!d	ifdd.�d1d2�Z"d3d4�Z#d5d6�Z$d	S);rrfzHTTP/1.1r,rcCst|tj�Sru)r��io�
TextIOBase)�streamrrr�
_is_textIO%szHTTPConnection._is_textIOcCsd|dur|��tvrdSdSt|d�r*dSzt|�}|jWStyLYn0t|t�r`t|�SdS)Nrr�)	�upper�_METHODS_EXPECTING_BODYr�r�nbytes�	TypeErrorr�r\r.)�bodyrWZmvrrr�_get_content_length+s

z"HTTPConnection._get_content_lengthN� cCsn||_||_||_d|_g|_d|_t|_d|_d|_	d|_
i|_|�||�\|_
|_|�|j
�tj|_dSru)�timeout�source_address�	blocksizerV�_buffer�_HTTPConnection__response�_CS_IDLE�_HTTPConnection__staterL�_tunnel_host�_tunnel_port�_tunnel_headers�
_get_hostport�host�port�_validate_host�socketZcreate_connection�_create_connection)r2r�r�r�r�r�rrrrYKszHTTPConnection.__init__cCs<|jrtd��|�||�\|_|_|r.||_n
|j��dS)Nz.Can't set up tunnel for established connection)rV�RuntimeErrorr�r�r�r��clear)r2r�r�rArrr�
set_tunnelaszHTTPConnection.set_tunnelcCs�|dur�|�d�}|�d�}||kr�zt||dd��}WnFty�||dd�dkrf|j}ntd||dd���Yn0|d|�}n|j}|r�|ddkr�|ddkr�|dd�}||fS)	Nr+�]r,r[znonnumeric port: '%s'r�[r�)�rfindrcr`�default_portr)r2r�r�r��jrrrr�ys

zHTTPConnection._get_hostportcCs
||_dSru)rK)r2�levelrrr�set_debuglevel�szHTTPConnection.set_debuglevelc
Cs
d|j�d�|jf}|g}|j��D]$\}}|�|�d|�d��d��q&|�d�|�d�|��~|j|j	|j
d�}|��\}}}|tj
jkr�|��td	|�d
|������|j�td�}	t|	�tkr�td��|	s�q|	d
vr�q|jdkr�td|	���q�dS)NsCONNECT %s:%d HTTP/1.0
�asciiz: �
rr;r�rWzTunnel connection failed: � r,r9r:rrg)r�r r�r�rnr1�sendrE�response_classrVrLrd�http�
HTTPStatusZOKrt�OSErrorrmr@r=r>r.rrKr]rF)
r2�connectrA�headerr��responserOrl�messager4rrr�_tunnel�s.�

zHTTPConnection._tunnelc
Csz|�|j|jf|j|j�|_z|j�tjtj	d�Wn2t
yf}z|jtjkrR�WYd}~n
d}~00|j
rv|��dS)Nr,)r�r�r�r�r�rVZ
setsockoptr�ZIPPROTO_TCPZTCP_NODELAYr��errnoZENOPROTOOPTr�r��r2�errrr��s�zHTTPConnection.connectcCsZt|_z4|j}|r d|_|��W|j}|rVd|_|��n|j}|rTd|_|��0dSru)r�r�rVrtr�)r2rVr�rrrrt�s

�zHTTPConnection.closecCs|jdur |jr|��nt��|jdkr8tdt|��t|d�r�|jdkrTtd�|�|�}|rt|jdkrttd�|�	|j
�}|s�q�|r�|�d�}|j�|�qtdSz|j�|�WnHt
y�t|tjj�r�|D]}|j�|�q�nt
dt|���Yn0dS)Nrzsend:r��sendIng a read()able�encoding file using iso-8859-1rCz9data should be a bytes-like object or an iterable, got %r)rV�	auto_openr�rrKr]r^r�r�r�r�r Zsendallr�r��collections�abc�Iterable�type)r2rr �	datablock�drrrr��s8






�zHTTPConnection.sendcCs|j�|�dSru)r�r1)r2r�rrr�_output�szHTTPConnection._outputccs^|jdkrtd�|�|�}|r2|jdkr2td�|�|j�}|sDqZ|rR|�d�}|Vq2dS)Nrr�r�rC)rKr]r�r�r�r )r2r{r r�rrr�_read_readable�s


zHTTPConnection._read_readableFcCs|j�d�d�|j�}|jdd�=|�|�|du�rt|d�rN|�|�}nVzt|�WnBty�zt|�}Wn"ty�tdt	|���Yn0Yn0|f}|D]R}|s�|j
dkr�td�q�|r�|jdkr�t
|�d�d	��d
�|d}|�|�q�|�r|jdk�r|�d�dS)N)rrr;r�zAmessage_body should be a bytes-like object or an iterable, got %rrzZero length chunk ignoredrf�Xr�r�s0

)r��extendrEr�r�r�rr��iterr�rKr]�	_http_vsnr.r )r2�message_body�encode_chunkedrMZchunksr�rrr�_send_outputs:


�
�zHTTPConnection._send_outputcCs�|jr|j��rd|_|jtkr(t|_n
t|j��|�|�||_|pHd}|�|�d|||j	f}|�
|�|��|jdk�r�|�s�d}|�
d�r�t|�\}}}}}|r�z|�d�}Wnty�|�d�}Yn0|�d|�n�|jr�|j}	|j}
n|j}	|j}
z|	�d�}Wnt�y0|	�d�}Yn0|	�d	�d
k�rNd|d}|
|jk�rh|�d|�n|�d�}|�dd
||
f�|�s�|�dd�ndS)N�/z%s %s %srfr[r�r�ZidnaZHostr+r�[�]z%s:%szAccept-EncodingZidentity)r�r|r�r��_CS_REQ_STARTEDr
�_validate_methodrL�_validate_path�
_http_vsn_strr��_encode_requestr�rarr r!�	putheaderr�r�r�r�r�r�rF)r2rWrX�	skip_host�skip_accept_encoding�requestZnetlocZnilZ
netloc_encr�r�Zhost_encrrr�
putrequest=sP






zHTTPConnection.putrequestcCs
|�d�S)Nr�)r )r2rrrrr��szHTTPConnection._encode_requestcCs,t�|�}|r(td|�d|���d���dS)Nz)method can't contain control characters. � (found at least �))�$_contains_disallowed_method_pchar_re�searchr`�group)r2rW�matchrrrr��s
��zHTTPConnection._validate_methodcCs,t�|�}|r(td|�d|���d���dS�Nz&URL can't contain control characters. rr��!_contains_disallowed_url_pchar_rerrr)r2rXr	rrrr��s


�zHTTPConnection._validate_pathcCs,t�|�}|r(td|�d|���d���dSr
r)r2r�r	rrrr��s


�zHTTPConnection._validate_hostcGs�|jtkrt��t|d�r$|�d�}t|�s:td|f��t|�}t|�D]\\}}t|d�rl|�d�||<nt	|t
�r�t|��d�||<t||�rJtd||f��qJd�
|�}|d|}|�|�dS)Nr r�zInvalid header name %rrzInvalid header value %rs
	s: )r�r�rr�r �_is_legal_header_namer`r��	enumerater�rcr\�_is_illegal_header_valuerEr�)r2r��valuesr�Z	one_valuer�rrrr��s"





zHTTPConnection.putheader�r�cCs*|jtkrt|_nt��|j||d�dS)Nr)r�r��_CS_REQ_SENTrr�)r2r�r�rrr�
endheaders�s
zHTTPConnection.endheaderscCs|�|||||�dSru)�
_send_request)r2rWrXr�rAr�rrrrszHTTPConnection.requestcCs�tdd�|D��}i}d|vr&d|d<d|vr6d|d<|j||fi|��d|vr�d	|vr�d
}|�||�}|dur�|dur�|jdkr�td|�d
}|�dd�q�|�dt|��nd
}|��D]\}	}
|�|	|
�q�t|t�r�t	|d�}|j
||d�dS)Ncss|]}|��VqdSru)r-)r�krrr�	<genexpr>	rz/HTTPConnection._send_request.<locals>.<genexpr>r�r,rzaccept-encodingrrirhFrzUnable to determine size of %rTzTransfer-EncodingrRzContent-Lengthr�r)�	frozensetrr�rKr]r�r\rnr�r)r)r2rWrXr�rAr�Zheader_namesZskipsZcontent_lengthrqr�rrrrs0	


zHTTPConnection._send_requestcCs�|jr|j��rd|_|jtks&|jr0t|j��|jdkrR|j|j|j|jd�}n|j|j|jd�}zLz|�	�Wnt
y�|���Yn0t|_|j
r�|��n||_|WS|���Yn0dS)Nrr�)r�r|r�rrrKr�rVrLrs�ConnectionErrorrtr�rU)r2r�rrr�getresponse5s.

�
zHTTPConnection.getresponse)NN)NF)FF)N)%r6r7r8r�r�rr��	HTTP_PORTr�r�rK�staticmethodr�r�r��_GLOBAL_DEFAULT_TIMEOUTrYr�r�r�r�r�rtr�r�r�r�rr�r�r�r�r�rrrrrrrrrsJ

�

 &
6�
	
�.rcsDeZdZeZdddejdfdddd��fdd�Z�fdd�Z�Z	S)�HTTPSConnectionNr�)�context�check_hostnamer�cs�tt|�j|||||	d�|dus2|dus2|durHddl}
|
�dtd�||_||_|durtt�	�}|j
durtd|_
|jtjk}|dur�|j
}|r�|s�td��|s�|r�|�||�|j
dur�d|_
||_|dur�||j_
dS)N)r�rzTkey_file, cert_file and check_hostname are deprecated, use a custom context instead.rZTzMcheck_hostname needs a SSL context with either CERT_OPTIONAL or CERT_REQUIRED)rvrrY�warnings�warn�DeprecationWarning�key_file�	cert_file�sslZ_create_default_https_contextZpost_handshake_authZverify_modeZ	CERT_NONErr`Zload_cert_chain�_context)r2r�r�r#r$r�r�rrr�r Zwill_verifyrxrrrY�s:���

zHTTPSConnection.__init__cs6t���|jr|j}n|j}|jj|j|d�|_dS)N)�server_hostname)rvr�r�r�r&Zwrap_socketrV)r2r'rxrrr��s

�zHTTPSConnection.connect)
r6r7r8�
HTTPS_PORTr�r�rrYr�r�rrrxrrys��$rc@seZdZdS)rN�r6r7r8rrrrr�src@seZdZdS)rNr)rrrrr�src@seZdZdS)rNr)rrrrr�src@seZdZdd�ZdS)rcCs|f|_||_dSru)�argsrO)r2rOrrrrY�szUnknownProtocol.__init__N�r6r7r8rYrrrrr�src@seZdZdS)rNr)rrrrr�src@seZdZdS)r	Nr)rrrrr	�sr	c@s$eZdZddd�Zdd�ZejZdS)r
NcCs|f|_||_||_dSru)r*�partial�expected)r2r,r-rrrrY�szIncompleteRead.__init__cCs2|jdurd|j}nd}d|jjt|j�|fS)Nz, %i more expectedr[z%s(%i bytes read%s))r-ryr6r.r,r�rrr�__repr__�s

�zIncompleteRead.__repr__)N)r6r7r8rYr.r#�__str__rrrrr
�s
r
c@seZdZdS)rNr)rrrrr�src@seZdZdS)r
Nr)rrrrr
�sr
c@seZdZdS)rNr)rrrrr�src@seZdZdS)rNr)rrrrr�src@seZdZdd�ZdS)rcCs|st|�}|f|_||_dSru)r^r*r4r�rrrrY�szBadStatusLine.__init__Nr+rrrrr�src@seZdZdd�ZdS)rcCst�|dt|f�dS)Nz&got more than %d bytes when reading %s)rrYr>)r2Z	line_typerrrrY�s�zLineTooLong.__init__Nr+rrrrr�src@seZdZdd�ZdS)rcOs(t�|d�tj|g|�Ri|��dS)Nr[)rrY�ConnectionResetError)r2�pos�kwrrrrY�szRemoteDisconnected.__init__Nr+rrrrr�sr)r)BZemail.parserrGZ
email.messager�r�r��rer��collections.abcr�Zurllib.parser�__all__rr(rNr�r�r�globals�updater��__members__rrr�r>r?�compile�	fullmatchr
rrrrr�r)r�ZMessager*rBrI�BufferedIOBaserrr%�ImportErrorrr1�	Exceptionrrrrrr	r
rr
rrrrr0rrrrrr�<module>Gsx


.]8


?>