Hacked By AnonymousFox

Current Path : /opt/alt/python38/lib/python3.8/site-packages/urllib3/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib/python3.8/site-packages/urllib3/__pycache__/connection.cpython-38.pyc

U

��`BI�	@sddlmZddlZddlZddlZddlZddlZddlZddlmZ	ddlm
Zddlm
Z
ddlmZddlmZdd	lmZzddlZejZWn,eefk
r�dZGd
d�de�ZYnXzeZWn$ek
r�Gdd
�d
e�ZYnXzeZWn&ek
�r Gdd�de�ZYnXddlmZddl m!Z!ddl"m#Z#m$Z$m%Z%m&Z&ddl'm(Z(m)Z)ddl*m+Z+m,Z,m-Z-ddl.m/Z/m0Z0m1Z1m2Z2m3Z3e�4e5�Z6ddd�Z7e�8ddd�Z9e�:d�Z;Gdd�dee<�ZGdd�de�Z=d d!�Z>d"d#�Z?Gd$d%�d%e<�Z@e�s
e@Z=e=ZAdS)&�)�absolute_importN)�error)�timeout�)�six)�HTTPConnection)�
HTTPException)�create_proxy_ssl_contextc@seZdZdS)�BaseSSLErrorN��__name__�
__module__�__qualname__�rr�C/opt/alt/python38/lib/python3.8/site-packages/urllib3/connection.pyr
sr
c@seZdZdS)�ConnectionErrorNrrrrrr!src@seZdZdS)�BrokenPipeErrorNrrrrrr*sr)�HTTPHeaderDict��__version__)�ConnectTimeoutError�NewConnectionError�SubjectAltNameWarning�SystemTimeWarning)�CertificateError�match_hostname)�SKIP_HEADER�SKIPPABLE_HEADERS�
connection)�assert_fingerprint�create_urllib3_context�resolve_cert_reqs�resolve_ssl_version�ssl_wrap_socket�Pi�)�http�httpsi��z[^-!#$%&'*+.^_`|~0-9a-zA-Z]cs�eZdZdZedZejejdfgZ	dZ
dd�Zedd��Z
e
jd	d��Z
d
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zd�fdd�	Zddd�Z�ZS)ra5
    Based on :class:`http.client.HTTPConnection` but provides an extra constructor
    backwards-compatibility layer between older and newer Pythons.

    Additional keyword parameters are used to configure attributes of the connection.
    Accepted parameters include:

    - ``strict``: See the documentation on :class:`urllib3.connectionpool.HTTPConnectionPool`
    - ``source_address``: Set the source address for the current connection.
    - ``socket_options``: Set specific options on the underlying socket. If not specified, then
      defaults are loaded from ``HTTPConnection.default_socket_options`` which includes disabling
      Nagle's algorithm (sets TCP_NODELAY to 1) unless the connection is behind a proxy.

      For example, if you wish to enable TCP Keep Alive in addition to the defaults,
      you might pass:

      .. code-block:: python

         HTTPConnection.default_socket_options + [
             (socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1),
         ]

      Or you may want to disable the defaults by passing an empty list (e.g., ``[]``).
    r%rFcOs`tjs|�dd�|�d�|_|�d|j�|_|�dd�|_|�dd�|_t	j
|f|�|�dS)N�strict�source_address�socket_options�proxy�proxy_config)r�PY2�pop�getr)�default_socket_optionsr*r+r,�_HTTPConnection�__init__)�self�args�kwrrrr2nszHTTPConnection.__init__cCs|j�d�S)a�
        Getter method to remove any trailing dots that indicate the hostname is an FQDN.

        In general, SSL certificates don't include the trailing dot indicating a
        fully-qualified domain name, and thus, they don't validate properly when
        checked against a domain name that includes the dot. In addition, some
        servers may not expect to receive the trailing dot when provided.

        However, the hostname with trailing dot is critical to DNS resolution; doing a
        lookup with the trailing dot will properly only resolve the appropriate FQDN,
        whereas a lookup without a trailing dot will search the system's search domain
        list. Thus, it's important to keep the original host around for use only in
        those cases where it's appropriate (i.e., when doing DNS lookup to establish the
        actual TCP connection across which we're going to send HTTP requests).
        �.)�	_dns_host�rstrip�r3rrr�hostszHTTPConnection.hostcCs
||_dS)z�
        Setter for the `host` property.

        We assume that only urllib3 uses the _dns_host attribute; httplib itself
        only uses `host`, and it seems reasonable that other libraries follow suit.
        N)r7)r3�valuerrrr:�sc
Cs�i}|jr|j|d<|jr$|j|d<ztj|j|jf|jf|�}WnXtk
rlt|d|j	|jf��Yn0t
k
r�}zt|d|��W5d}~XYnX|S)zoEstablish a socket connection and set nodelay settings on it.

        :return: New socket connection.
        r)r*z0Connection to %s timed out. (connect timeout=%s)z(Failed to establish a new connection: %sN)r)r*r�create_connectionr7�portr�
SocketTimeoutrr:�SocketErrorr)r3Zextra_kw�conn�errr�	_new_conn�s2


��
���zHTTPConnection._new_conncCst|dd�S)N�_tunnel_host)�getattrr9rrr�_is_using_tunnel�szHTTPConnection._is_using_tunnelcCs ||_|��r|��d|_dS)Nr)�sockrE�_tunnel�	auto_open�r3r@rrr�
_prepare_conn�szHTTPConnection._prepare_conncCs|��}|�|�dS�N)rBrJrIrrr�connect�szHTTPConnection.connectcOs8t�|�}|r"td||��f��tj|||f|�|�S)� zAMethod cannot contain non-token characters %r (found at least %r))�_CONTAINS_CONTROL_CHAR_RE�search�
ValueError�groupr1�
putrequest)r3�method�urlr4�kwargs�matchrrrrR�s

��zHTTPConnection.putrequestcGs\tdd�|D��s&tj||f|��n2t�|���tkrXtdd�t	t
jtt���f��dS)rMcss |]}t|t�o|tkVqdSrK)�
isinstance�strr)�.0�vrrr�	<genexpr>�sz+HTTPConnection.putheader.<locals>.<genexpr>z+urllib3.util.SKIP_HEADER only supports '%s'z', 'N)
�anyr1�	putheaderr�
ensure_str�lowerrrP�join�maprX�title�sorted)r3�header�valuesrrrr]�s��zHTTPConnection.putheaderNcsN|dkri}n|��}ddd�|D�kr2t�|d<tt|�j||||d�dS)N�
user-agentcss|]}t�|���VqdSrK�rr^r_�rY�krrrr[�sz)HTTPConnection.request.<locals>.<genexpr>�
User-Agent)�body�headers)�copy�_get_default_user_agent�superr�request)r3rSrTrkrl��	__class__rrrp�s
zHTTPConnection.requestcCs&|pi}tdd�|D��}d|k}d|k}|j||||d�d|krR|�dt��|��D]\}}	|�||	�qZd|kr�|�d	d
�|��|dk	�rtjtf}
t	||
�r�|f}|D]`}|s�q�t	|t�s�|�
d�}tt|��d
d�}t
|�
��}
|
d7}
|
|7}
|
d7}
|�|
�q�|�d�dS)z�
        Alternative to the common request method, which sends the
        body with chunked encoding and not as one block
        cSsg|]}t�|����qSrrgrhrrr�
<listcomp>�sz2HTTPConnection.request_chunked.<locals>.<listcomp>zaccept-encodingr:)�skip_accept_encoding�	skip_hostrfrjztransfer-encodingzTransfer-Encoding�chunkedN�utf8�s
s0

)�setrRr]rn�itemsZ
endheadersr�string_types�bytesrW�encode�hex�len�	bytearray�send)r3rSrTrkrlZheader_keysrtrurdr;Zstringish_types�chunkZlen_strZto_sendrrr�request_chunked�sB�



zHTTPConnection.request_chunked)NN)NN)rr
r�__doc__�port_by_scheme�default_port�socket�IPPROTO_TCP�TCP_NODELAYr0�is_verifiedr2�propertyr:�setterrBrErJrLrRr]rpr��
__classcell__rrrqrrKs"

	


rc	@sjeZdZdZedZdZdZdZdZ	dZ
dZdZddddde
jddfdd�Zd
dd�Zd	d
�Zdd�ZdS)�HTTPSConnectionz�
    Many of the parameters to this constructor are passed to the underlying SSL
    socket by means of :py:func:`urllib3.util.ssl_wrap_socket`.
    r&NFc
KsDtj|||f||d�|
��||_||_||_||_|	|_d|_dS)N)r(rr&)rr2�key_file�	cert_file�key_password�ssl_context�server_hostnameZ	_protocol)r3r:r=r�r�r�r(rr�r�r5rrrr2$szHTTPSConnection.__init__c

Csv|dkr$|jdk	r|jj}ntd�}||_||_||_||_||_||_|oVt	j
�|�|_|oht	j
�|�|_
|	|_dS)zX
        This method should only be called once, before the connection is used.
        N)r��verify_moder!r�r��	cert_reqsr��assert_hostnamer�os�path�
expanduser�ca_certs�ca_cert_dir�ca_cert_data)
r3r�r�r�r�r�r�rr�r�rrr�set_cert>s

zHTTPSConnection.set_certc	Cs|��}|j}d}|��rJ|jr0|�||�}d}||_|��d|_|j}|}|j	dk	r^|j	}t
j��t
k}|r�t�d�t
�t�d}|jdkr�d}tt|j�t|j�d�|_|j}t|j�|_|js�|js�|js�|r�t|d�r�|��t||j|j |j!|j|j|j|||d�
|_|�r^|jdk�r^t|jd��r^|j�"�d	k�r^t�d
|j|j�"�ft#�|j$�r~t$|jj%dd�|j$�nd|jt&j'k�r�t(|dd��s�|j)dk	�r�|j�%�}|�*d
d��s�t�d�|�t+�t,||j)�p�|�|jt&j-k�p�|j$dk	|_.dS)NFTrzWSystem time is way off (before {0}). This will probably lead to SSL verification errors)�ssl_versionr��load_default_certs)
rFZkeyfileZcertfiler�r�r�r�r�r��
tls_in_tls�version>�TLSv1�TLSv1.1z�Negotiating TLSv1/TLSv1.1 by default is deprecated and will be disabled in urllib3 v2.0.0. Connecting to '%s' with '%s' can be enabled by explicitly opting-in with 'ssl_version')Zbinary_form�check_hostnameZsubjectAltNamerz�Certificate for {0} has no `subjectAltName`, falling back to check for a `commonName` for now. This feature is being removed by major browsers and deprecated by RFC 2818. (See https://github.com/urllib3/urllib3/issues/497 for details.))/rBr:rE�tls_in_tls_required�_connect_tls_proxyrFrGrHrCr��datetime�date�today�RECENT_DATE�warnings�warn�formatrr�r r"r�r!r�r�r�r�r��hasattrr�r#r�r�r�r��DeprecationWarningrZgetpeercert�sslZ	CERT_NONErDr�r/r�_match_hostnameZ
CERT_REQUIREDr�)	r3r@�hostnamer�r�Zis_time_offZdefault_ssl_context�context�certrrrrL_s�
���

���������
�����
�
��
��	�zHTTPSConnection.connectcCsX|j}|j}|rt|||d�St|j|j|j|j|j�}d|_	t||j|j|j||d�S)zY
        Establish a TLS connection to the proxy using the provided SSL context.
        )rFr�r�T)rFr�r�r�r�r�)
r,r�r#r	r�r�r�r�r�r�)r3r�r@r,r�rrrr��s0��
�z"HTTPSConnection._connect_tls_proxy)	NNNNNNNNN)rr
rr�r�r�r�r�r�r�r�rr�r��_GLOBAL_DEFAULT_TIMEOUTr2r�rLr�rrrrr�s<�
�
!xr�c
CsLzt||�Wn8tk
rF}zt�d||�||_�W5d}~XYnXdS)Nz@Certificate did not match expected hostname: %s. Certificate: %s)rr�log�warningZ
_peer_cert)r�Zasserted_hostnamerArrrr��s�r�cCsdtS)Nzpython-urllib3/%srrrrrrn
srnc@seZdZdZdS)�DummyConnectionz-Used to detect a failed ConnectionCls import.N)rr
rr�rrrrr�sr�)B�
__future__rr��loggingr��rer�r�rr?rr>�packagesrZpackages.six.moves.http_clientrr1rZ
util.proxyr	r�ZSSLErrorr
�ImportError�AttributeError�
BaseExceptionr�	NameError�	Exceptionr�_collectionsr�_versionr�
exceptionsrrrrZpackages.ssl_match_hostnamerr�utilrrrZ	util.ssl_rr r!r"r#�	getLoggerrr�r�r�r��compilerN�objectr�r�rnr�ZVerifiedHTTPSConnectionrrrr�<module>s\



Jk

Hacked By AnonymousFox1.0, Coded By AnonymousFox