OwlCyberSecurity - MANAGER
Edit File: connections.cpython-36.opt-1.pyc
3 �U�f�%������������������@���s&��d�dl�Z�d�dlZd�dlZd�dlmZ�d�dlmZ�d�dlmZ�d�dlm Z �y(d�dl Z d�dl mZmZm Z �d�dlZW�n<�ek r����d�dljZ d�dlmZmZm Z �d�dljZY�nX�G�dd��de j�ZG�d d ��d e j�ZG�dd��de�ZG�d d��de�ZG�dd��de�ZG�dd��de�Zdd��Zdd��ZdS�)�����N)�python_version)�SSL)�nonblocking)�i18n)�_CS_REQ_SENT�_CS_IDLE�ResponseNotReadyc���������������@���s���e�Zd�Zdd��ZdS�)�HTTPResponsec�������������C���s4���t�|�jtj�stj|�j�|�_|�jj|||||��d�S�)N)� isinstance�fpr���ZNonBlockingFile�set_callback)�self�rs�ws�ex� user_data�callback��r����!/usr/lib/python3.6/connections.pyr��� ���s����zHTTPResponse.set_callbackN)�__name__� __module__�__qualname__r���r���r���r���r���r ������s���r ���c���������������@���s@���e�Zd�ZeZdejfdd�Zdd��Zdd��Z dd ��Z d d��ZdS�)�HTTPConnectionNc�������������C���s^���t���dkr tjj|�|||d��ntjj|�||��g�|�_g�|�_g�|�_d�|�_d�|�_d|�_ ||�_ d�S�)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�portr���r���r���r���r���(���s���� zHTTPConnection.__init__c�������������C���s"���||�_�||�_||�_||�_||�_d�S�)N)r���r���r���r���r ���)r ���r���r���r���r���r���r���r���r���r���5���s ����zHTTPConnection.set_callbackc�������������C���s ���||�_�d�S�)N)r!���)r ���Z user_agentr���r���r����set_user_agent=���s����zHTTPConnection.set_user_agentc�������������C���s����|�j�r|�j�j��rd|�_�|�jtks&|�j�r,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__stater���r���Z debuglevel�response_class�sockr ���r���r���r���r���r����beginr���� will_close�close)r ����responser���r���r����getresponseB���s ���� zHTTPConnection.getresponsec�������������C���s���t�jj|���|�jj|�j��d�S�)N)r���r����connectr&���� settimeoutr���)r ���r���r���r���r,���s���s����zHTTPConnection.connect)r���r���r���r ���r%���r����DEFAULT_TIMEOUTr���r���r$���r+���r,���r���r���r���r���r���%���s��� 1r���c���������������@���sB���e�Zd�Zdddejfdd�Zdd��Zd dd�Zd d ��Zdd��Z dS�)�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����zHTTPProxyConnection.__init__c�������������C���s.���|�j�|�j|�j��tj|���|�j�|�j|�j��d�S�)N)r2���r0���r1���r���r,���r3���r4���)r ���r���r���r���r,�������s���� zHTTPProxyConnection.connectr���c�������������C���sN���|�j�}|�j|�jkr$|d�t|�j��}d||f�}tj|�|||d��|�j���d�S�)N�:zhttp://%s%s)� skip_host)r3���r4����default_port�strr���� putrequest�_add_proxy_headers)r ����method�urlr;����hostnameZnewurlr���r���r���r>�������s����zHTTPProxyConnection.putrequestc�������������C���sX���|�j�s d�S�d|�j�|�jf�}tjtj|��jtjd�tjd��}|�jddtj|����d�S�)Nz%s:%s� ��zProxy-AuthorizationzBasic %s) r5���r6����base64Zencodestringr����bstr�replace� putheaderZsstr)r ���ZuserpassZenc_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���r2�������s����z!HTTPProxyConnection._set_hostport)r���) r���r���r���r���r.���r���r,���r>���r?���r2���r���r���r���r���r/���x���s��� r/���c���������������@���s2���e�Zd�ZeZejjZddej fdd�Z dd��ZdS�)�HTTPSConnectionNc�������������C���s$���t�j|�|||d��|pg�}||�_d�S�)N)r���)r���r���� trusted_certs)r ���r"���r#���rJ���r���r���r���r���r�������s����zHTTPSConnection.__init__c������� ������C���s����t�j|�j|�jt�jt�j�}x�|D�]�}|\}}}}}yt�j�|||�}W�n�t�jk r^���d}wY�nX�y"|j|�j|�jf��|j|�j ��W�n$�t�jk r����|j ���d}wY�nX�P�qW�|dkr�t�jd��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-���r���r)���r���� SSLSocketrJ���r&����init_ssl) r ����results�rZafZsocktype�protoZ canonnameZsar&���r���r���r���r,�������s*���� zHTTPSConnection.connect)r���r���r���r ���r%���r���rI���r<���r���r.���r���r,���r���r���r���r���rI�������s ���rI���c���������������@���s���e�Zd�Zdd��ZdS�)�HTTPSProxyResponsec�������������C���s���t�j|���d|�_d�S�)Nr���)r ���r'���r(���)r ���r���r���r���r'�������s���� zHTTPSProxyResponse.beginN)r���r���r���r'���r���r���r���r���rR�������s���rR���c���������������@���sB���e�Zd�ZejZddddejfdd�Zdd��Zddd�Z d d ��Z dS�)�HTTPSProxyConnectionNc���������� ���C���s*���t�j|�||||||d��|pg�}||�_d�S�)N)r���)r/���r���rJ���)r ���r7���r"���r#���r8���r9���rJ���r���r���r���r���r�������s���� zHTTPSProxyConnection.__init__c�������������C���s����t�j|���d|�j|�jf�}tj|�d|��|�j���tj|���|�j}t |�_tj |��}||�_|j���|jdkr�|�j���t j||j|j|j��tj|�j|�j�|�_|�jj���d�S�)Nz%s:%sZCONNECT�����)r/���r,���r3���r4���r���r>���r?���Z endheadersr%���rR���r+���r)���Zstatus� xmlrpclibZ ProtocolError�reason�msgr���rM���r&���rJ���rN���)r ���r"���r%���r*���r���r���r���r,�������s ���� zHTTPSProxyConnection.connectr���c�������������C���s���t�j|�|||d�S�)N)r;���)r���r>���)r ���r@���rA���r;���r���r���r���r>�������s����zHTTPSProxyConnection.putrequestc�������������C���s���t�j|���|�jd|�j��d�S�)Nz User-Agent)r/���r?���rH���r!���)r ���r���r���r���r?�������s���� z'HTTPSProxyConnection._add_proxy_headers)r���)r���r���r���rI���r<���r���r.���r���r,���r>���r?���r���r���r���r���rS�������s��� rS���c�������������C���s$���|�dkrdS�t�j|��}�|�jd�S�dS�)zJ Convert Internationalized domain name from Punycode (RFC3492) to Unicode N�idna)r���rF����decode)rB���r���r���r����idn_puny_to_unicode����s���� rZ���c�������������C���s*���|�dkrdS�t�j|��}�t�j|�jd��S�dS�)zZ Convert domain name to Punycode (RFC3492). Hostname can be instance of string or Unicode NrX���)r���Zustr�encode)rB���r���r���r����idn_ascii_to_puny��s���� r\���)rE���Zencodings.idnaZ encodingsrK����platformr���Zrhnr���r���r���r���r���r���r���rU����ImportErrorZhttp.clientZclientZ xmlrpc.clientr ���r���r/���rI���rR���rS���rZ���r\���r���r���r���r����<module> ���s,��� S,&.