Your IP : 3.144.255.198


Current Path : /opt/alt/python310/lib64/python3.10/http/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/http/__pycache__/client.cpython-310.opt-2.pyc

o

6��f���@sN	ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z
ddlmZgd�Z
dZdZdZdZdZd	Ze��ejj�d
d�ejj��D�ZdZd
Ze�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,zddl-Z-Wn	e.y�YnwGd 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.d/�d/e2�Z8Gd0d1�d1e2�Z9Gd2d3�d3e9�Z:Gd4d5�d5e9�Z;Gd6d7�d7e9�Z<Gd8d9�d9e2�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�2/opt/alt/python310/lib64/python3.10/http/client.py�
<dictcomp>lsri�ds[^:\s][^:\r\n]*s\n(?![ \t])|\r(?![ \t\n])z[- ]z[-]>ZPATCHZPUTZPOST�datac
Cs\	z|�d�WSty-}zt|j|j|j|jd|��||j|j�|f�d�d}~ww)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@�eZdZdd�ZdS)�HTTPMessagecCsl	|��d}t|�}g}d}|��D] }|d|���|kr"d}n
|dd���s,d}|r3|�|�q|S)N�:r�)�lower�len�keys�isspace�append)�selfr&�nZlstZhit�linerrr�getallmatchingheaders�s	
�z!HTTPMessage.getallmatchingheadersN)�__name__�
__module__�__qualname__r5rrrrr*�sr*cCs\	g}	|�td�}t|�tkrtd��|�|�t|�tkr&tdt��|dvr-	|Sq)NTr,�header linezgot more than %d headers��
�
�)�readline�_MAXLINEr.rr1�_MAXHEADERSr)�fp�headersr4rrr�
_read_headers�s
�rCcCs.	t|�}d�|��d�}tjj|d��|�S)Nr=�
iso-8859-1)�_class)rC�join�decode�email�parserZParserZparsestr)rArErBZhstringrrr�
parse_headers�s	rJcseZdZd@dd�Zdd�Zdd�Zd	d
�Zdd�Z�fd
d�Z�fdd�Z	dd�Z
dd�ZdAdd�Zdd�Z
dd�Zdd�Zdd�ZdAdd �Zd!d"�Zd#d$�Zd%d&�ZdBd(d)�ZdBd*d+�ZdB�fd,d-�	Zd.d/�Zd0d1�Zd2d3�ZdAd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Zd>d?�Z �Z!S)CrrNcCsR|�d�|_||_||_d|_|_t|_t|_t|_	t|_
t|_t|_t|_
dS)N�rb)ZmakefilerA�
debuglevel�_methodrB�msg�_UNKNOWN�version�status�reason�chunked�
chunk_left�length�
will_close)r2�sockrL�method�urlrrr�__init__�s
zHTTPResponse.__init__cCst|j�td�d�}t|�tkrtd��|jdkr!tdt|��|s't	d��z|�
dd�\}}}Wn!tySz|�
dd�\}}d}WntyPd}YnwYnw|�d	�sa|�
�t|��zt|�}|d
ksn|dkrrt|��Wnty~t|��w|||fS)Nr,rDzstatus linerzreply:z-Remote end closed connection without response��zHTTP/ri�)�strrAr>r?r.rrL�print�reprr�split�
ValueError�
startswith�_close_connr�int)r2r4rPrQrRrrr�_read_statuss<
���
��
zHTTPResponse._read_statusc	Cs�|jdurdS	|��\}}}|tkrnt|j�}|jdkr#td|�~q||_|_|�	�|_
|dvr8d|_n
|�d�rAd|_nt
|��t|j�|_|_|jdkre|j��D]\}}td|d	|�qX|j�d
�}|rz|��dkrzd|_d|_nd|_|��|_d|_|j�d
�}|r�|js�zt|�|_Wnty�d|_Yn
w|jdkr�d|_nd|_|tks�|tks�d|kr�dks�n|jdkr�d|_|js�|js�|jdur�d|_dSdSdSdS)NTrzheaders:)zHTTP/1.0zHTTP/0.9�
zHTTP/1.��header:r+�transfer-encodingrSF�content-lengthr���HEAD)rBreZCONTINUErCrArLr^�coderQ�striprRrPrbrrJrN�items�getr-rSrT�_check_closerVrUrdraZ
NO_CONTENTZNOT_MODIFIEDrM)	r2rPrQrRZskipped_headers�hdr�valZtr_encrUrrr�begin7sf



�






�
�
�

�zHTTPResponse.begincCsv|j�d�}|jdkr|rd|��vrdSdS|j�d�rdS|r)d|��vr)dS|j�d�}|r9d|��vr9dSdS)NZ
connectionrg�closeTFz
keep-alivezproxy-connection)rBrprPr-)r2ZconnZpconnrrrrqs
zHTTPResponse._check_closecCs|j}d|_|��dS�N)rAru)r2rArrrrc�szHTTPResponse._close_conncs6zt���W|jr|��dSdS|jr|��wwrv)�superrurArc�r2��	__class__rrru�s
�
�zHTTPResponse.closecs"t���|jr|j��dSdSrv)rw�flushrArxryrrr{�s
�zHTTPResponse.flushcCs	dS)NTrrxrrr�readable�szHTTPResponse.readablecCs	|jduSrv)rArxrrr�isclosed�s
zHTTPResponse.isclosedcCs�	|jdurdS|jdkr|��dS|jr|�|�S|durS|jdur,||jkr,|j}|j�|�}|s<|r<|��|S|jdurQ|jt|�8_|jsQ|��|S|jdur^|j��}nz|�|j�}Wnt	yr|���wd|_|��|S)Nr=rlr)
rArMrcrS�
_read_chunkedrU�readr.�
_safe_readr
)r2�amt�srrrr�s>



�
�zHTTPResponse.readcCs�	|jdurdS|jdkr|��dS|jr|�|�S|jdur0t|�|jkr0t|�d|j�}|j�|�}|s@|r@|��|S|jdurS|j|8_|jsS|��|S)Nrrl)	rArMrcrS�_readinto_chunkedrUr.�
memoryview�readinto)r2�br3rrrr��s(




�zHTTPResponse.readintocCsh|j�td�}t|�tkrtd��|�d�}|dkr!|d|�}zt|d�WSty3|���w)Nr,z
chunk size�;r�)	rAr>r?r.r�findrdrarc)r2r4�irrr�_read_next_chunk_sizes
�z"HTTPResponse._read_next_chunk_sizecCs<	|j�td�}t|�tkrtd��|sdS|dvrdSq)NTr,ztrailer liner:)rAr>r?r.r�r2r4rrr�_read_and_discard_trailers�z&HTTPResponse._read_and_discard_trailercCsf|j}|s1|dur|�d�z|��}Wntytd��w|dkr.|��|��d}||_|S)Nr[r=r)rTr�r�rar
r�rc)r2rTrrr�_get_chunk_left*s
�zHTTPResponse._get_chunk_leftcCs�g}z:	|��}|dur
n*|dur#||kr#|�|�|��|||_n|�|�|��|dur3||8}d|_qd�|�WStyJtd�|���w)NTrr=)r�r1r�rTrFr
)r2r��valuerTrrrr~Bs&
��zHTTPResponse._read_chunkedcCs�d}t|�}z:	|��}|dur|WSt|�|kr(|�|�}|||_||WS|d|�}|�|�}||d�}||7}d|_qtyQtt|d|����w)Nr)r�r�r.�_safe_readintorTr
�bytes)r2r�Ztotal_bytesZmvbrTr3Ztemp_mvbrrrr�Xs(



��zHTTPResponse._readinto_chunkedcCs0	|j�|�}t|�|krt||t|���|Srv)rArr.r
)r2r�rrrrr�ps
zHTTPResponse._safe_readcCs<	t|�}|j�|�}||krtt|d|��||��|Srv)r.rAr�r
r�)r2r�r�r3rrrr�|szHTTPResponse._safe_readinto���cCs�	|jdus|jdkr
dS|jr|�|�S|jdur&|dks#||jkr&|j}|j�|�}|s6|r6|��|S|jdurD|jt|�8_|S�Nrlr=r)rArMrS�_read1_chunkedrU�read1rcr.)r2r3�resultrrrr��s

�zHTTPResponse.read1cCs4|jdus
|jdkrdS|jr|�|�S|j�|�S)Nrlr=)rArMrS�
_peek_chunked�peek)r2r3rrrr��s

zHTTPResponse.peekcs�|jdus
|jdkrdS|jrt��|�S|jdur&|dks#||jkr&|j}|j�|�}|s6|r6|��|S|jdurD|jt|�8_|Sr�)rArMrSrwr>rUrcr.)r2�limitr�ryrrr>�s
�zHTTPResponse.readlinecCsd|��}|dus|dkrdSd|kr|ksn|}|j�|�}|jt|�8_|s0td��|S)Nrr=)r�rAr�rTr.r
)r2r3rTrrrrr��szHTTPResponse._read1_chunkedcCsBz|��}Wn
tyYdSw|durdS|j�|�d|�S)Nr=)r�r
rAr�)r2r3rTrrrr��s�zHTTPResponse._peek_chunkedcCs
|j��Srv)rA�filenorxrrrr���
zHTTPResponse.filenocCsD	|jdur	t��|j�|�p|}t|t�st|d�s|Sd�|�S)N�__iter__z, )rBrZget_all�
isinstancer]�hasattrrF)r2r&�defaultrBrrr�	getheader�s

zHTTPResponse.getheadercCs 	|jdur	t��t|j���Srv)rBr�listrorxrrr�
getheaders�s
zHTTPResponse.getheaderscCs|Srvrrxrrrr��szHTTPResponse.__iter__cC�	|jSrv)rBrxrrr�info�szHTTPResponse.infocCr�rv)rYrxrrr�geturls	zHTTPResponse.geturlcCr�rv)rQrxrrr�getcodeszHTTPResponse.getcode)rNNrv)r�)"r6r7r8rZrertrqrcrur{r|r}rr�r�r�r�r~r�r�r�r�r�r>r�r�r�r�r�r�r�r�r��
__classcell__rrryrr�s>
	!H

("


	
rc@seZdZdZdZeZeZdZ	dZ
edd��Zedd��Z
d	ejd	d
fdd�Zd7d
d�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd8d d!�Z		d9d"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);rrgzHTTP/1.1r,rcCs	t|tj�Srv)r��io�
TextIOBase)�streamrrr�
_is_textIO szHTTPConnection._is_textIOcCsf	|dur|��tvr
dSdSt|d�rdSzt|�}|jWSty'Ynwt|t�r1t|�SdS)Nrr)	�upper�_METHODS_EXPECTING_BODYr�r��nbytes�	TypeErrorr�r]r.)�bodyrXZmvrrr�_get_content_length&s 
�
z"HTTPConnection._get_content_lengthN� cCsn||_||_||_d|_g|_d|_t|_d|_d|_	d|_
i|_|�||�\|_
|_|�|j
�tj|_dSrv)�timeout�source_address�	blocksizerW�_buffer�_HTTPConnection__response�_CS_IDLE�_HTTPConnection__staterM�_tunnel_host�_tunnel_port�_tunnel_headers�
_get_hostport�host�port�_validate_host�socketZcreate_connection�_create_connection)r2r�r�r�r�r�rrrrZFszHTTPConnection.__init__cCs@	|jrtd��|�||�\|_|_|r||_dS|j��dS)Nz.Can't set up tunnel for established connection)rW�RuntimeErrorr�r�r�r��clear)r2r�r�rBrrr�
set_tunnel\s
zHTTPConnection.set_tunnelcCs�|dur`|�d�}|�d�}||krIzt||dd��}Wn#tyA||dd�dkr3|j}ntd||dd���Ynw|d|�}n|j}|r`|ddkr`|ddkr`|dd�}||fS)	Nr+�]r,r\znonnumeric port: '%s'r�[r�)�rfindrdra�default_portr)r2r�r�r��jrrrr�ts"

��zHTTPConnection._get_hostportcCs
||_dSrv)rL)r2�levelrrr�set_debuglevel�r�zHTTPConnection.set_debuglevelc
Csd|j�d�|jf}|g}|j��D]\}}|�|�d|�d��d��q|�d�|�d�|��~|j|j	|j
d�}|��\}}}|tj
jkrZ|��td	|�d
|������	|j�td�}	t|	�tkrmtd
��|	sqdS|	dvrwdS|jdkr�td|	���q[)NsCONNECT %s:%d HTTP/1.0
�asciiz: �
rr;r=�rXzTunnel connection failed: � Tr,r9r:rrh)r�rr�r�ror1�sendrF�response_classrWrMre�http�
HTTPStatusZOKru�OSErrorrnrAr>r?r.rrLr^rG)
r2�connectrB�headerr��responserPrm�messager4rrr�_tunnel�s2�

�zHTTPConnection._tunnelc
Cs�	t�d||j|j�|�|j|jf|j|j�|_z|j�t	j
t	jd�Wnty>}z
|j
t
jkr4�WYd}~nd}~ww|jrH|��dSdS)Nzhttp.client.connectr,)�sys�auditr�r�r�r�r�rWZ
setsockoptr�ZIPPROTO_TCPZTCP_NODELAYr��errnoZENOPROTOOPTr�r��r2�errrr��s �����zHTTPConnection.connectcCs`	t|_z|j}|rd|_|��W|j}|r d|_|��dSdS|j}|r/d|_|��wwrv)r�r�rWrur�)r2rWr�rrrru�s$���
�zHTTPConnection.closecCs"	|jdur|jr|��nt��|jdkrtdt|��t|d�r\|jdkr+td�|�|�}|r;|jdkr;td�	|�	|j
�}|sG	dS|rN|�d�}t�
d||�|j�|�q<t�
d||�z	|j�|�WdSty�t|tjj�r�|D]}|j�|�q|YdStd	t|���w)
Nrzsend:r�sendIng a read()able�encoding file using iso-8859-1r,rDzhttp.client.sendz9data should be a bytes-like object or an iterable, got %r)rW�	auto_openr�rrLr^r_r�r�rr�rr�r�Zsendallr�r��collections�abc�Iterable�type)r2rr�	datablock�drrrr��sF





�
�	���zHTTPConnection.sendcCs	|j�|�dSrv)r�r1)r2r�rrr�_output�szHTTPConnection._outputccs`�|jdkr
td�|�|�}|r|jdkrtd�	|�|j�}|s%dS|r,|�d�}|Vq)Nrr�r�TrD)rLr^r�rr�r)r2r|rr�rrr�_read_readable�s�


�zHTTPConnection._read_readableFcCs 	|j�d�d�|j�}|jdd�=|�|�|dur�t|d�r'|�|�}n)zt|�WntyLzt|�}WntyItdt	|���wYnw|f}|D])}|s`|j
dkr_td�qR|rv|jdkrvt
|�d�d	��d
�|d}|�|�qR|r�|jdkr�|�d�dSdSdSdS)N)r=r=r;rzAmessage_body should be a bytes-like object or an iterable, got %rrzZero length chunk ignoredrg�Xr�r�s0

)r��extendrFr�r�r�r�r��iterr�rLr^�	_http_vsnr.r)r2�message_body�encode_chunkedrNZchunks�chunkrrr�_send_outputsF

����

��'zHTTPConnection._send_outputcCs�	|jr|j��rd|_|jtkrt|_nt|j��|�|�||_|p%d}|�|�d|||j	f}|�
|�|��|jdkr�|s�d}|�
d�rRt|�\}}}}}|rqz|�d�}Wntyi|�d�}Ynw|�d|�nN|jr{|j}	|j}
n|j}	|j}
z|	�d�}Wnty�|	�d�}Ynw|	�d	�d
kr�d|d}|
|jkr�|�d|�n|�d�}|�dd
||
f�|s�|�dd�dSdS	dS)N�/z%s %s %srgr\r�r�ZidnaZHostr+r�[�]z%s:%szAccept-EncodingZidentity)r�r}r�r��_CS_REQ_STARTEDr
�_validate_methodrM�_validate_path�
_http_vsn_strr��_encode_requestr�rbrrr �	putheaderr�r�r�r�r�r�rG)r2rXrY�	skip_host�skip_accept_encoding�requestZnetlocZnilZ
netloc_encr�r�Zhost_encrrr�
putrequest;sX






��


�
zHTTPConnection.putrequestcCs
|�d�S)Nr�)r)r2r�rrrr��s
zHTTPConnection._encode_requestcC�.	t�|�}|rtd|�d|���d���dS)Nz)method can't contain control characters. � (found at least �))�$_contains_disallowed_method_pchar_re�searchra�group)r2rX�matchrrrr��s
���zHTTPConnection._validate_methodcCr�Nz&URL can't contain control characters. rr��!_contains_disallowed_url_pchar_rerrr)r2rYrrrrr���


��zHTTPConnection._validate_pathcCrrr)r2r�rrrrr��r
zHTTPConnection._validate_hostcGs�	|jtkr	t��t|d�r|�d�}t|�std|f��t|�}t|�D].\}}t|d�r7|�d�||<nt	|t
�rEt|��d�||<t||�rTtd||f��q&d�
|�}|d|}|�|�dS)Nrr�zInvalid header name %rrzInvalid header value %rs
	s: )r�r�rr�r�_is_legal_header_namerar��	enumerater�rdr]�_is_illegal_header_valuerFr�)r2r��valuesr�Z	one_valuer�rrrr��s&




�
zHTTPConnection.putheader�r�cCs,	|jtkr
t|_nt��|j||d�dS)Nr)r�r��_CS_REQ_SENTrr�)r2r�r�rrr�
endheaders�s

zHTTPConnection.endheaderscCs	|�|||||�dSrv)�
_send_request)r2rXrYr�rBr�rrrr�szHTTPConnection.requestcCs�tdd�|D��}i}d|vrd|d<d|vrd|d<|j||fi|��d|vrZd	|vrYd
}|�||�}|durQ|durP|jdkrHtd|�d
}|�dd�n|�dt|��nd
}|��D]
\}	}
|�|	|
�q`t|t�rut	|d�}|j
||d�dS)Ncss�|]}|��VqdSrv)r-)r�krrr�	<genexpr>s�z/HTTPConnection._send_request.<locals>.<genexpr>r�r,r�zaccept-encodingr�rjriFrzUnable to determine size of %rTzTransfer-EncodingrSzContent-Lengthr�r)�	frozensetr�r�rLr^r�r]ror�r(r)r2rXrYr�rBr�Zheader_namesZskipsZcontent_lengthrrr�rrrrs4	
��

zHTTPConnection._send_requestcCs�	|jr|j��rd|_|jtks|jrt|j��|jdkr*|j|j|j|jd�}n	|j|j|jd�}z&z|�	�Wnt
yF|���wt|_|j
rT|��|WS||_|WS|���)Nrr�)r�r}r�rrrLr�rWrMrt�ConnectionErrorrur�rV)r2r�rrr�getresponse3s4

���zHTTPConnection.getresponse)NN)NF)FFrv)%r6r7r8r�r�rr��	HTTP_PORTr�r�rL�staticmethodr�r�r��_GLOBAL_DEFAULT_TIMEOUTrZr�r�r�r�r�rur�r�r�r�r�r�r�r�r�r�rr�rrrrrrrsL


�
 (
6
�	
�.rcsFeZdZ	eZdddejdfdddd��fdd�Z�fdd�Z�Z	S)�HTTPSConnectionNr�)�context�check_hostnamer�cs�tt|�j|||||	d�|dus|dus|dur$ddl}
|
�dtd�||_||_|durEt�	�}|j
dkr=|�dg�|jdurEd|_|j
tjk}|durR|j}|rZ|sZtd��|s^|rl|�||�|jdurld|_||_|dury||j_dSdS)	N)r�rzTkey_file, cert_file and check_hostname are deprecated, use a custom context instead.r[rgzhttp/1.1TzMcheck_hostname needs a SSL context with either CERT_OPTIONAL or CERT_REQUIRED)rwrrZ�warnings�warn�DeprecationWarning�key_file�	cert_file�sslZ_create_default_https_contextr�Zset_alpn_protocolsZpost_handshake_authZverify_modeZ	CERT_NONErraZload_cert_chain�_context)r2r�r�r!r"r�r�rrr�rZwill_verifyryrrrZ~s>��


�zHTTPSConnection.__init__cs8	t���|jr
|j}n|j}|jj|j|d�|_dS)N)�server_hostname)rwr�r�r�r$Zwrap_socketrW)r2r%ryrrr��s

�zHTTPSConnection.connect)
r6r7r8�
HTTPS_PORTr�r�rrZr�r�rrryrrws��'rc@�eZdZdS)rN�r6r7r8rrrrr�src@r')rNr(rrrrr��rc@r')rNr(rrrrr�r)rc@r))rcCs|f|_||_dSrv)�argsrP)r2rPrrrrZ�s
zUnknownProtocol.__init__N�r6r7r8rZrrrrr��rc@r')rNr(rrrrr�r)rc@r')r	Nr(rrrrr	�r)r	c@s$eZdZddd�Zdd�ZejZdS)r
NcCs|f|_||_||_dSrv)r*�partial�expected)r2r-r.rrrrZ�s
zIncompleteRead.__init__cCs2|jdurd|j}nd}d|jjt|j�|fS)Nz, %i more expectedr\z%s(%i bytes read%s))r.rzr6r.r-r�rrr�__repr__�s

�zIncompleteRead.__repr__rv)r6r7r8rZr/r"�__str__rrrrr
�s

r
c@r')rNr(rrrrr�r)rc@r')r
Nr(rrrrr
�r)r
c@r')rNr(rrrrr�r)rc@r')rNr(rrrrr�r)rc@r))rcCs|st|�}|f|_||_dSrv)r_r*r4r�rrrrZ�s
zBadStatusLine.__init__Nr+rrrrr�r,rc@r))rcCst�|dt|f�dS)Nz&got more than %d bytes when reading %s)rrZr?)r2Z	line_typerrrrZ�s
�zLineTooLong.__init__Nr+rrrrr�r,rc@r))rcOs(t�|d�tj|g|�Ri|��dS)Nr\)rrZ�ConnectionResetError)r2�pos�kwrrrrZ�szRemoteDisconnected.__init__Nr+rrrrr�r,r)r)BZemail.parserrHZ
email.messager�r�r��rer�r�Zcollections.abcr�Zurllib.parser�__all__rr&rOr�r�r�globals�updater��__members__rrr?r@�compile�	fullmatchrrr
r	rr�r(r�ZMessager*rCrJ�BufferedIOBaserrr#�ImportErrorrr1�	Exceptionrrrrrr	r
rr
rrrrr1rrrrrr�<module>s~F


+`�
;

?>