HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/libcloud/__pycache__/http.cpython-310.pyc
o

;j>(�@s�dZddlZddlZddlmZddlZddlmZzddl	m
Z
Wney1ddlm
Z
YnwddgZ
dZd	ZGd
d�de�ZGdd�d�ZGd
d�de�ZGdd�d�ZdS)z|
Subclass for httplib.HTTPSConnection with optional certificate name
verification, depending on libcloud.security settings.
�N)�HTTPAdapter)�urlparse)�PoolManager�LibcloudBaseConnection�LibcloudConnection��<cs&eZdZ�fdd�Zddd�Z�ZS)�SignedHTTPSAdaptercs||_||_t���dS�N)�	cert_file�key_file�super�__init__��selfrr��	__class__��A/opt/saltstack/salt/lib/python3.10/site-packages/libcloud/http.pyr.szSignedHTTPSAdapter.__init__FcCst||||j|jd�|_dS)N)Z	num_pools�maxsize�blockrr)rrrZpoolmanager)rZconnectionsrrrrr�init_poolmanager3s�z#SignedHTTPSAdapter.init_poolmanager)F)�__name__�
__module__�__qualname__rr�
__classcell__rrrrr	-sr	c@sbeZdZdZdZdZdZdZdZdZ	dZ
dZdd�Zdd�Z
dd	�Zd
d�Zdd
�Zddd�ZdS)rzk
    Base connection class to inherit from.

    Note: This class should not be instantiated directly.
    NFcCst��|_dSr
)�requestsZSession�session�rrrrrQ�zLibcloudBaseConnection.__init__cCsj|j|d�}|d}|d}|d}|d}|d}||_||_||_||_||_d|_||d�|j_d	S)
a�
        Set a HTTP proxy which will be used with this connection.
        This will override any proxy environment variables.

        :param proxy_url: Proxy URL (e.g. http://<hostname>:<port> without
                          authentication and
                          http://<username>:<password>@<hostname>:<port> for
                          basic auth authentication information.
        :type proxy_url: ``str``
        ��	proxy_urlrr���T��http�httpsN)	�_parse_proxy_url�proxy_scheme�
proxy_host�
proxy_port�proxy_username�proxy_password�http_proxy_usedrZproxies)rr!�result�scheme�host�port�username�passwordrrr�set_http_proxyTs�z%LibcloudBaseConnection.set_http_proxycCs�t�|�}|jdvrtd��|jr|jstd��|j}|j|j}}|j}d|vrK|�dd�d}|�dd�}t|�dkrAtd	��|d|d}	}
nd
}	d
}
||||	|
fS)z�
        Parse and validate a proxy URL.

        :param proxy_url: Proxy URL (e.g. http://hostname:3128)
        :type proxy_url: ``str``

        :rtype: ``tuple`` (``scheme``, ``hostname``, ``port``)
        r%z)Only http and https proxies are supportedzOproxy_url must be in the following format: <scheme>://<proxy host>:<proxy port>�@rr�:r"zURL is in an invalid formatN)rr0�
ValueError�hostnamer2�netloc�split�len)rr!�parsedr)r*r+r:Zusername_passwordr;r,r-rrrr(ss&
	
�z'LibcloudBaseConnection._parse_proxy_urlcCstjj|_dSr
)�libcloud�securityZVERIFY_SSL_CERT�verifyrrrr�
_setup_verify�rz$LibcloudBaseConnection._setup_verifycKsP|�dtjj�}|jdurdSt|t�r#d}t�|t	�|d|_
dS||_
dS)N�ca_certFz�Providing a list of CA trusts is no longer supported since libcloud 2.0. Using the first element in the list. See http://libcloud.readthedocs.io/en/latest/other/changes_in_2_0.html#providing-a-list-of-ca-trusts-is-no-longer-supportedr)�getr>r?Z
CA_CERTS_PATHr@�
isinstance�list�warnings�warn�DeprecationWarningrB)r�kwargsZ
ca_certs_path�msgrrr�_setup_ca_cert�s

�
z%LibcloudBaseConnection._setup_ca_certcCs|j�dt||��dS)z\
        Setup request signing by mounting a signing
        adapter to the session
        zhttps://N)rZmountr	rrrr�_setup_signing�sz%LibcloudBaseConnection._setup_signing)NN)rrr�__doc__rr)r*r+r,r-r.rBrr5r(rArKrLrrrrr=s &c@s�eZdZdZdZdZddd�Zedd��Zddd�Z	dd	d
�Z
dd�Zd
d�Zedd��Z
edd��Zdd�Zdd�Zdd�Zdd�ZdS)rNcKs�|dur|rdnd}d�|dkrdn|||dvrd�|�nd�|_|�dd�}|��|��t�|�|�d	t�|j_	d
|vsDd|vrL|j
d
i|��|rV|j|d�dSdS)Nr'r&z	{}://{}{}�)�PrNz:{}�r!�timeoutrrr r)�formatr1�poprArKrr�DEFAULT_REQUEST_TIMEOUTrrQrLr5)rr1r2ZsecurerIr0r!rrrr�s �
�zLibcloudConnection.__init__cCs|jdur|jS|jS)zN
        The option for SSL verification given to underlying requests
        N)rBr@rrrr�verification�szLibcloudConnection.verificationFcCsHt�|j|�}|j|d�}|jj|��|||t||j|jj	|d�	|_
dS)N��headers)	�method�url�datarWZallow_redirects�streamr@rQ�hooks)r�urljoinr1�_normalize_headersr�request�lower�ALLOW_REDIRECTSrUrQ�response)rrXrY�bodyrW�rawr[r\rrrr_�s�zLibcloudConnection.requestc	Cs`|j|d�}tj|d�|j|g�||d�}|j�|�}|jj|||jdur(|jn|j	d�|_
dS)NrVrP)rZrW)r[r@)r^r�Request�joinr1rZprepare_request�sendrBr@rb)	rrXrYrcrWrdr[�reqZpreppedrrr�prepared_request�s�z#LibcloudConnection.prepared_requestcCs|jSr
)rbrrrr�getresponse�szLibcloudConnection.getresponsecCsd|jjvr|jjd=|jjS)Nzcontent-encoding)rbrWrrrr�
getheaders�s
zLibcloudConnection.getheaderscC�|jjSr
)rb�status_coderrrr�status�zLibcloudConnection.statuscCs|jjdkrdS|jjS)Ni�)rbrm�textrrrr�reasonszLibcloudConnection.reasoncCsdSr
rrrrr�connectszLibcloudConnection.connectcCrlr
)rb�contentrrrr�read�zLibcloudConnection.readcCs|j��dSr
)rb�closerrrrrvszLibcloudConnection.closecCs8|pi}|��D]\}}t|ttf�rt|�||<q|Sr
)�itemsrD�int�float�str)rrW�key�valuerrrr^s�z%LibcloudConnection._normalize_headersr
)NNFFN)NNFF)rrrrQr1rbr�propertyrUr_rirjrkrnrqrrrtrvr^rrrrr�s&






c@sdeZdZdZdd�Zddd�Zddd�Zd	d
�Zedd��Z	ed
d��Z
edd��Zedd��ZdS)�HttpLibResponseProxyz}
    Provides a proxy pattern around the :class:`requests.Response`
    object to a :class:`httplib.HTTPResponse` object
    cCs
||_dSr
)�	_response)rrbrrrr's
zHttpLibResponseProxy.__init__NcCrlr
)rrp)r�amtrrrrt*ruzHttpLibResponseProxy.readcCs ||jj��vr|jj|S|S)zi
        Get the contents of the header name, or default
        if there is no matching header.
        )rrW�keys)r�name�defaultrrr�	getheader-szHttpLibResponseProxy.getheadercCst|jj���S)z:
        Return a list of (header, value) tuples.
        )rErrWrwrrrrrk7szHttpLibResponseProxy.getheaderscCrlr
)rrmrrrrrn=rozHttpLibResponseProxy.statuscCrlr
)rrqrrrrrqArozHttpLibResponseProxy.reasoncCsdS)NZ11rrrrr�versionEszHttpLibResponseProxy.versioncCrlr
)rrsrrrrrcJszHttpLibResponseProxy.bodyr
)
rrrrMrrtr�rkr}rnrqr�rcrrrrr~!s





r~)rMrFrZrequests.adaptersrZlibcloud.securityr>Zlibcloud.utils.py3rZurllib3.poolmanagerr�ImportErrorZ%requests.packages.urllib3.poolmanager�__all__rarTr	rrr~rrrr�<module>s$�{i