509318396
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3
 Û`ð%  ã               @   s&  d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZ d dlm	Z	 y(d dl
Z
d dl
mZmZmZ d dlZW n< ek
r¬   d dljZ
d dlmZmZmZ d dljZY nX G dd„ de
jƒZG d	d
„ d
e
jƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZdd„ Zdd„ ZdS )é    N)Úpython_version)ÚSSL)Únonblocking)Úi18n)Ú_CS_REQ_SENTÚ_CS_IDLEÚResponseNotReadyc               @   s   e Zd Zdd„ ZdS )ÚHTTPResponsec             C   s4   t | jtjƒstj| jƒ| _| jj|||||ƒ d S )N)Ú
isinstanceÚfpr   ZNonBlockingFileÚset_callback)ÚselfÚrsÚwsÚexÚ	user_dataÚcallback© r   ú!/usr/lib/python3.6/connections.pyr       s    zHTTPResponse.set_callbackN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r	      s   r	   c               @   s@   e Zd ZeZdejfdd„Zdd„ Zdd„ Z	dd	„ Z
d
d„ ZdS )ÚHTTPConnectionNc             C   s^   t ƒ dkr tjj| |||d� ntjj| ||ƒ g | _g | _g | _d | _d | _d| _	|| _
d S )Nz2.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Úportr   r   r   r   r   (   s    
zHTTPConnection.__init__c             C   s"   || _ || _|| _|| _|| _d S )N)r   r   r   r   r    )r   r   r   r   r   r   r   r   r   r   5   s
    zHTTPConnection.set_callbackc             C   s
   || _ d S )N)r!   )r   Z
user_agentr   r   r   Úset_user_agent=   s    zHTTPConnection.set_user_agentc             C   s®   | j r| j jƒ rd| _ | jtks&| j r,tƒ ‚| jdkrH| j| j| jƒ}n| j| jƒ}| jrv|j	| j
| j| j| j| jƒ |jƒ  |jtjksŽt‚t| _|jr¤| jƒ  n|| _ |S )z!Get the response from the server.Nr   )Z_HTTPConnection__responseZisclosedZ_HTTPConnection__stater   r   Z
debuglevelÚresponse_classÚsockr    r   r   r   r   r   ÚbeginÚ
will_closer   Z_UNKNOWNÚAssertionErrorr   Úclose)r   Úresponser   r   r   ÚgetresponseB   s"    

zHTTPConnection.getresponsec             C   s   t jj| ƒ | jj| jƒ d S )N)r   r   Úconnectr&   Ú
settimeoutr   )r   r   r   r   r-   s   s    zHTTPConnection.connect)r   r   r   r	   r%   r   ÚDEFAULT_TIMEOUTr   r   r$   r,   r-   r   r   r   r   r   %   s   1r   c               @   sB   e Zd Zdddejfdd„Zdd„ Zddd„Zd	d
„ Zdd„ Z	dS )ÚHTTPProxyConnectionNc             C   sP   t j| ||d� | j| j | _| _| j||ƒ | j| j | _| _|| _	|| _
d S )N)r   )r   r   r"   r#   Ú_HTTPProxyConnection__proxyÚ _HTTPProxyConnection__proxy_portÚ_set_hostportÚ_hostÚ_portÚ_HTTPProxyConnection__usernameÚ_HTTPProxyConnection__password)r   Úproxyr"   r#   ÚusernameÚpasswordr   r   r   r   r   y   s    zHTTPProxyConnection.__init__c             C   s.   | j | j| jƒ tj| ƒ | j | j| jƒ d S )N)r3   r1   r2   r   r-   r4   r5   )r   r   r   r   r-   ‡   s    
zHTTPProxyConnection.connectr   c             C   sN   | j }| j| jkr$|d t| jƒ }d||f }tj| |||d� | jƒ  d S )Nú:zhttp://%s%s)Ú	skip_host)r4   r5   Údefault_portÚstrr   Ú
putrequestÚ_add_proxy_headers)r   ÚmethodÚurlr<   ÚhostnameZnewurlr   r   r   r?   Ž   s    zHTTPProxyConnection.putrequestc             C   sX   | j s
d S d| j | jf }tjtj|ƒƒjtjdƒtjdƒƒ}| jddtj|ƒ ƒ d S )Nz%s:%sÚ
Ú zProxy-AuthorizationzBasic %s)	r6   r7   Úbase64Zencodestringr   ÚbstrÚreplaceÚ	putheaderZsstr)r   ZuserpassZenc_userpassr   r   r   r@   ™   s
    $z&HTTPProxyConnection._add_proxy_headersc             C   s   | j ||ƒ\| _| _d S )N)Z_get_hostportr"   r#   )r   r"   r#   r   r   r   r3   ¡   s    z!HTTPProxyConnection._set_hostport)r   )
r   r   r   r   r/   r   r-   r?   r@   r3   r   r   r   r   r0   x   s   
r0   c               @   s2   e Zd ZeZejjZddej	fdd„Z
dd„ ZdS )ÚHTTPSConnectionNc             C   s$   t j| |||d� |pg }|| _d S )N)r   )r   r   Útrusted_certs)r   r"   r#   rK   r   r   r   r   r   ¨   s    zHTTPSConnection.__init__c       	      C   sÞ   t j| j| jt jt jƒ}x”|D ]Œ}|\}}}}}yt j |||ƒ}W n t jk
r^   d}wY nX y"|j| j| jfƒ |j| j	ƒ W n$ t jk
r¦   |j
ƒ  d}wY nX P qW |dkrÀt jdƒ‚tj|| jƒ| _| jjƒ  dS )z'Connect to a host on a given (SSL) portNz0Unable to connect to the host and port specified)ÚsocketZgetaddrinfor"   r#   Z	AF_UNSPECZSOCK_STREAMÚerrorr-   r.   r   r*   r   Ú	SSLSocketrK   r&   Úinit_ssl)	r   ÚresultsÚrZafZsocktypeÚprotoZ	canonnameZsar&   r   r   r   r-   ®   s*    

zHTTPSConnection.connect)r   r   r   r	   r%   r   rJ   r=   r   r/   r   r-   r   r   r   r   rJ   ¤   s
   rJ   c               @   s   e Zd Zdd„ ZdS )ÚHTTPSProxyResponsec             C   s   t j| ƒ d| _d S )Nr   )r	   r'   r(   )r   r   r   r   r'   Ë   s    
zHTTPSProxyResponse.beginN)r   r   r   r'   r   r   r   r   rS   Ê   s   rS   c               @   sB   e Zd ZejZddddejfdd„Zdd„ Zddd„Z	d	d
„ Z
dS )ÚHTTPSProxyConnectionNc          	   C   s*   t j| ||||||d� |pg }|| _d S )N)r   )r0   r   rK   )r   r8   r"   r#   r9   r:   rK   r   r   r   r   r   Ò   s    
zHTTPSProxyConnection.__init__c             C   s¦   t j| ƒ d| j| jf }tj| d|ƒ | jƒ  tj| ƒ | j}t	| _tj
| ƒ}|| _|jƒ  |jdkr†| jƒ  tj||j|j|jƒ‚tj| j| jƒ| _| jjƒ  d S )Nz%s:%sZCONNECTéÈ   )r0   r-   r4   r5   r   r?   r@   Z
endheadersr%   rS   r,   r*   ZstatusÚ	xmlrpclibZProtocolErrorÚreasonÚmsgr   rN   r&   rK   rO   )r   r"   r%   r+   r   r   r   r-   Ù   s     



zHTTPSProxyConnection.connectr   c             C   s   t j| |||d�S )N)r<   )r   r?   )r   rA   rB   r<   r   r   r   r?   õ   s    zHTTPSProxyConnection.putrequestc             C   s   t j| ƒ | jd| jƒ d S )Nz
User-Agent)r0   r@   rI   r!   )r   r   r   r   r@   ø   s    
z'HTTPSProxyConnection._add_proxy_headers)r   )r   r   r   rJ   r=   r   r/   r   r-   r?   r@   r   r   r   r   rT   Ï   s   
rT   c             C   s$   | dkrdS t j| ƒ} | jdƒS dS )zJ Convert Internationalized domain name from Punycode (RFC3492) to Unicode NÚidna)r   rG   Údecode)rC   r   r   r   Úidn_puny_to_unicodeý   s    
r[   c             C   s*   | dkrdS t j| ƒ} t j| jdƒƒS dS )zZ Convert domain name to Punycode (RFC3492). Hostname can be instance of string or Unicode NrY   )r   ZustrÚencode)rC   r   r   r   Úidn_ascii_to_puny  s    
r]   )rF   Zencodings.idnaZ	encodingsrL   Úplatformr   Zrhnr   r   r   r   r   r   r   rV   ÚImportErrorZhttp.clientZclientZxmlrpc.clientr	   r   r0   rJ   rS   rT   r[   r]   r   r   r   r   Ú<module>
   s,   
S,&.