Your IP : 3.133.127.131


Current Path : /usr/lib/python3.6/site-packages/rhn/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/rhn/__pycache__/connections.cpython-36.opt-1.pyc

3

�U�f�%�@s&ddlZddlZddlZddlmZddlmZddlmZddlm	Z	y(ddl
Z
ddl
mZmZm
Z
ddlZWn<ek
r�ddljZ
ddlmZmZm
Z
ddljZYnXGdd�de
j�ZGd	d
�d
e
j�ZGdd�de�ZGd
d�de�ZGdd�de�ZGdd�de�Zdd�Zdd�ZdS)�N)�python_version)�SSL)�nonblocking)�i18n)�_CS_REQ_SENT�_CS_IDLE�ResponseNotReadyc@seZdZdd�ZdS)�HTTPResponsecCs4t|jtj�stj|j�|_|jj|||||�dS)N)�
isinstance�fprZNonBlockingFile�set_callback)�self�rs�ws�ex�	user_data�callback�r�!/usr/lib/python3.6/connections.pyr szHTTPResponse.set_callbackN)�__name__�
__module__�__qualname__rrrrrr	sr	c@s@eZdZeZdejfdd�Zdd�Zdd�Z	dd	�Z
d
d�ZdS)�HTTPConnectionNcCs^t�dkr tjj||||d�ntjj|||�g|_g|_g|_d|_d|_d|_	||_
dS)Nz2.6.1)�timeoutz#rhn.connections $Revision$ (python))r�httplibr�__init__�_cb_rs�_cb_ws�_cb_ex�
_cb_user_data�_cb_callback�_user_agentr)r
�host�portrrrrr(s
zHTTPConnection.__init__cCs"||_||_||_||_||_dS)N)rrrrr )r
rrrrrrrrr5s
zHTTPConnection.set_callbackcCs
||_dS)N)r!)r
Z
user_agentrrr�set_user_agent=szHTTPConnection.set_user_agentcCs�|jr|jj�rd|_|jtks&|jr,t��|jdkrH|j|j|j�}n|j|j�}|jrv|j	|j
|j|j|j
|j�|j�t|_|jr�|j�n||_|S)z!Get the response from the server.Nr)Z_HTTPConnection__responseZisclosedZ_HTTPConnection__staterrZ
debuglevel�response_class�sockr rrrrr�beginr�
will_close�close)r
�responserrr�getresponseBs 

zHTTPConnection.getresponsecCstjj|�|jj|j�dS)N)rr�connectr&�
settimeoutr)r
rrrr,sszHTTPConnection.connect)rrrr	r%r�DEFAULT_TIMEOUTrrr$r+r,rrrrr%s
1rc@sBeZdZdddejfdd�Zdd�Zd
dd�Zd	d
�Zdd�Z	dS)�HTTPProxyConnectionNcCsPtj|||d�|j|j|_|_|j||�|j|j|_|_||_	||_
dS)N)r)rrr"r#�_HTTPProxyConnection__proxy� _HTTPProxyConnection__proxy_port�
_set_hostport�_host�_port�_HTTPProxyConnection__username�_HTTPProxyConnection__password)r
�proxyr"r#�username�passwordrrrrryszHTTPProxyConnection.__init__cCs.|j|j|j�tj|�|j|j|j�dS)N)r2r0r1rr,r3r4)r
rrrr,�s
zHTTPProxyConnection.connectrcCsN|j}|j|jkr$|dt|j�}d||f}tj||||d�|j�dS)N�:zhttp://%s%s)�	skip_host)r3r4�default_port�strr�
putrequest�_add_proxy_headers)r
�method�urlr;�hostnameZnewurlrrrr>�szHTTPProxyConnection.putrequestcCsX|js
dSd|j|jf}tjtj|��jtjd�tjd��}|jddtj|��dS)Nz%s:%s�
�zProxy-AuthorizationzBasic %s)	r5r6�base64Zencodestringr�bstr�replace�	putheaderZsstr)r
ZuserpassZenc_userpassrrrr?�s
$z&HTTPProxyConnection._add_proxy_headerscCs|j||�\|_|_dS)N)Z
_get_hostportr"r#)r
r"r#rrrr2�sz!HTTPProxyConnection._set_hostport)r)
rrrrr.rr,r>r?r2rrrrr/xs

r/c@s2eZdZeZejjZddej	fdd�Z
dd�ZdS)�HTTPSConnectionNcCs$tj||||d�|pg}||_dS)N)r)rr�
trusted_certs)r
r"r#rJrrrrr�szHTTPSConnection.__init__c	Cs�tj|j|jtjtj�}x�|D]�}|\}}}}}ytj|||�}Wntjk
r^d}wYnXy"|j|j|jf�|j|j	�Wn$tjk
r�|j
�d}wYnXPqW|dkr�tjd��tj||j
�|_|jj�dS)z'Connect to a host on a given (SSL) portNz0Unable to connect to the host and port specified)�socketZgetaddrinfor"r#Z	AF_UNSPECZSOCK_STREAM�errorr,r-rr)r�	SSLSocketrJr&�init_ssl)	r
�results�rZafZsocktype�protoZ	canonnameZsar&rrrr,�s*

zHTTPSConnection.connect)rrrr	r%rrIr<rr.rr,rrrrrI�s
rIc@seZdZdd�ZdS)�HTTPSProxyResponsecCstj|�d|_dS)Nr)r	r'r()r
rrrr'�s
zHTTPSProxyResponse.beginN)rrrr'rrrrrR�srRc@sBeZdZejZddddejfdd�Zdd�Zddd�Z	d	d
�Z
dS)�HTTPSProxyConnectionNc	Cs*tj|||||||d�|pg}||_dS)N)r)r/rrJ)r
r7r"r#r8r9rJrrrrr�s
zHTTPSProxyConnection.__init__cCs�tj|�d|j|jf}tj|d|�|j�tj|�|j}t	|_tj
|�}||_|j�|jdkr�|j�t
j||j|j|j��tj|j|j�|_|jj�dS)Nz%s:%sZCONNECT��)r/r,r3r4rr>r?Z
endheadersr%rRr+r)Zstatus�	xmlrpclibZ
ProtocolError�reason�msgrrMr&rJrN)r
r"r%r*rrrr,�s 



zHTTPSProxyConnection.connectrcCstj||||d�S)N)r;)rr>)r
r@rAr;rrrr>�szHTTPSProxyConnection.putrequestcCstj|�|jd|j�dS)Nz
User-Agent)r/r?rHr!)r
rrrr?�s
z'HTTPSProxyConnection._add_proxy_headers)r)rrrrIr<rr.rr,r>r?rrrrrS�s
rScCs$|dkrdStj|�}|jd�SdS)zJ Convert Internationalized domain name from Punycode (RFC3492) to Unicode N�idna)rrF�decode)rBrrr�idn_puny_to_unicode�s
rZcCs*|dkrdStj|�}tj|jd��SdS)zZ Convert domain name to Punycode (RFC3492). Hostname can be instance of string or Unicode NrX)rZustr�encode)rBrrr�idn_ascii_to_punys
r\)rEZencodings.idnaZ	encodingsrK�platformrZrhnrrrrrrrrU�ImportErrorZhttp.clientZclientZ
xmlrpc.clientr	rr/rIrRrSrZr\rrrr�<module>
s,
S,&.

?>