Hacked By AnonymousFox

Current Path : /lib/python3.6/site-packages/rhn/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/rhn/__pycache__/connections.cpython-36.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�|jtjks�t�t|_|jr�|j�n||_|S)z!Get the response from the server.Nr)Z_HTTPConnection__responseZisclosedZ_HTTPConnection__staterrZ
debuglevel�response_class�sockr rrrrr�begin�
will_closerZ_UNKNOWN�AssertionErrorr�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)r3r1r2rr-r4r5)r
rrrr-�s
zHTTPProxyConnection.connectrcCsN|j}|j|jkr$|dt|j�}d||f}tj||||d�|j�dS)N�:zhttp://%s%s)�	skip_host)r4r5�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)	r6r7�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#rrrr3�sz!HTTPProxyConnection._set_hostport)r)
rrrrr/rr-r?r@r3rrrrr0xs

r0c@s2eZdZeZejjZddej	fdd�Z
dd�ZdS)�HTTPSConnectionNcCs$tj||||d�|pg}||_dS)N)r)rr�
trusted_certs)r
r"r#rKrrrrr�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�	SSLSocketrKr&�init_ssl)	r
�results�rZafZsocktype�protoZ	canonnameZsar&rrrr-�s*

zHTTPSConnection.connect)rrrr	r%rrJr=rr/rr-rrrrrJ�s
rJc@seZdZdd�ZdS)�HTTPSProxyResponsecCstj|�d|_dS)Nr)r	r'r()r
rrrr'�s
zHTTPSProxyResponse.beginN)rrrr'rrrrrS�srSc@sBeZdZejZddddejfdd�Zdd�Zddd�Z	d	d
�Z
dS)�HTTPSProxyConnectionNc	Cs*tj|||||||d�|pg}||_dS)N)r)r0rrK)r
r8r"r#r9r:rKrrrrr�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��)r0r-r4r5rr?r@Z
endheadersr%rSr,r*Zstatus�	xmlrpclibZ
ProtocolError�reason�msgrrNr&rKrO)r
r"r%r+rrrr-�s 



zHTTPSProxyConnection.connectrcCstj||||d�S)N)r<)rr?)r
rArBr<rrrr?�szHTTPSProxyConnection.putrequestcCstj|�|jd|j�dS)Nz
User-Agent)r0r@rIr!)r
rrrr@�s
z'HTTPSProxyConnection._add_proxy_headers)r)rrrrJr=rr/rr-r?r@rrrrrT�s
rTcCs$|dkrdStj|�}|jd�SdS)zJ Convert Internationalized domain name from Punycode (RFC3492) to Unicode N�idna)rrG�decode)rCrrr�idn_puny_to_unicode�s
r[cCs*|dkrdStj|�}tj|jd��SdS)zZ Convert domain name to Punycode (RFC3492). Hostname can be instance of string or Unicode NrY)rZustr�encode)rCrrr�idn_ascii_to_punys
r])rFZencodings.idnaZ	encodingsrL�platformrZrhnrrrrrrrrV�ImportErrorZhttp.clientZclientZ
xmlrpc.clientr	rr0rJrSrTr[r]rrrr�<module>
s,
S,&.

Hacked By AnonymousFox1.0, Coded By AnonymousFox