%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core18/current/usr/lib/python3/dist-packages/urllib3/__pycache__/
Upload File :
Create Path :
Current File : //snap/core18/current/usr/lib/python3/dist-packages/urllib3/__pycache__/connection.cpython-36.pyc

3

�;g�4�@s�ddlmZddlZddlZddlZddlZddlZddlZddlmZ	m
ZddlZddl
Z
ddlmZddlmZyddlZejZWn,eefk
r�dZGdd�de�ZYnXyeZWn$ek
r�Gdd	�d	e�ZYnXd
dlmZmZmZmZd
dl m!Z!m"Z"d
d
l#m$Z$m%Z%m&Z&m'Z'm(Z(d
dl)m*Z*d
dl+m,Z,ej-e.�Z/ddd�Z0ej1dd
d
�Z2ej3d�Z4Gdd�de5�Z6Gdd�dee5�ZGdd�de�Z7Gdd�de7�Z8dd�Z9e�r�e7Z:e8Z7ne6Z7dS)�)�absolute_importN)�error�timeout)�HTTPConnection)�
HTTPExceptionc@seZdZdS)�BaseSSLErrorN)�__name__�
__module__�__qualname__�rr�4/usr/lib/python3/dist-packages/urllib3/connection.pyrsrc@seZdZdS)�ConnectionErrorN)rr	r
rrrrr
sr
�)�NewConnectionError�ConnectTimeoutError�SubjectAltNameWarning�SystemTimeWarning)�match_hostname�CertificateError)�resolve_cert_reqs�resolve_ssl_version�assert_fingerprint�create_urllib3_context�ssl_wrap_socket)�
connection)�HTTPHeaderDict�Pi�)�http�httpsi�z[^-!#$%&'*+.^_`|~0-9a-zA-Z]c@seZdZdZdS)�DummyConnectionz-Used to detect a failed ConnectionCls import.N)rr	r
�__doc__rrrrrDsrc@s^eZdZdZedZejejdfgZ	dZ
dd�Zdd�Zd	d
�Z
dd�Zd
d�Zddd�ZdS)ra{
    Based on httplib.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.

        .. note:: This is ignored for Python 2.6. It is only applied for 2.7 and 3.x

      - ``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::

            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., ``[]``).
    rrFcOsZtjr|jdd�|jd�|_tjdkr4|jdd�|jd|j�|_t	j
|f|�|�dS)N�strict�source_address���socket_options)r#r$)�sixZPY3�pop�getr"�sys�version_info�default_socket_optionsr%�_HTTPConnection�__init__)�self�args�kwrrrr-ms
zHTTPConnection.__init__cCs�i}|jr|j|d<|jr$|j|d<ytj|j|jf|jf|�}WnXtk
rlt|d|j|jf��Yn0t	k
r�}zt
|d|��WYdd}~XnX|S)zp Establish 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%rZcreate_connection�host�portr�
SocketTimeoutr�SocketErrorr)r.Zextra_kw�conn�errr�	_new_conn�s 

zHTTPConnection._new_conncCs$||_t|dd�r |j�d|_dS)N�_tunnel_hostr)�sock�getattr�_tunnel�	auto_open)r.r5rrr�
_prepare_conn�szHTTPConnection._prepare_conncCs|j�}|j|�dS)N)r7r=)r.r5rrr�connect�szHTTPConnection.connectcOs8tj|�}|r"td||j�f��tj|||f|�|�S)zSend a request to the serverzAMethod cannot contain non-token characters %r (found at least %r))�_CONTAINS_CONTROL_CHAR_RE�search�
ValueError�groupr,�
putrequest)r.�method�urlr/�kwargs�matchrrrrC�s
zHTTPConnection.putrequestNcCst|dk	r|ni�}d|k}d|k}|j||||d�x |j�D]\}}|j||�q@Wd|krl|jdd�|j�|dk	�rtjtjf}	t||	�r�|f}xj|D]b}
|
s�q�t|
tj�s�|
j	d�}
t
t|
��d	d�}|j|j	d
��|jd�|j|
�|jd�q�W|jd�dS)
z�
        Alternative to the common request method, which sends the
        body with chunked encoding and not as one block
        Nzaccept-encodingr1)�skip_accept_encoding�	skip_hostztransfer-encodingzTransfer-EncodingZchunked�utf8r#zutf-8s
s0

)
rrC�itemsZ	putheaderZ
endheadersr&Zstring_typesZbinary_type�
isinstance�encode�hex�len�send)r.rDrEZbodyZheadersrHrI�header�valueZstringish_types�chunkZlen_strrrr�request_chunked�s8





zHTTPConnection.request_chunked)NN)rr	r
r �port_by_scheme�default_port�socketZIPPROTO_TCPZTCP_NODELAYr+�is_verifiedr-r7r=r>rCrTrrrrrIsrc@s8eZdZedZdZddddejdfdd�Zdd�Z	dS)�HTTPSConnectionrNc	Ks8tj|||f||d�|��||_||_||_d|_dS)N)r!rr)rr-�key_file�	cert_file�ssl_contextZ	_protocol)	r.r1r2rZr[r!rr\r0rrrr-�szHTTPSConnection.__init__cCsN|j�}|j|�|jdkr2ttd�td�d�|_t||j|j|jd�|_	dS)N)�ssl_version�	cert_reqs)r9�keyfile�certfiler\)
r7r=r\rrrrrZr[r9)r.r5rrrr>�s

zHTTPSConnection.connect)
rr	r
rUrVr]rWZ_GLOBAL_DEFAULT_TIMEOUTr-r>rrrrrY�s
rYc@s6eZdZdZdZdZdZdZdZddd�Z	dd�Z
dS)�VerifiedHTTPSConnectionz[
    Based on httplib.HTTPSConnection but wraps the socket with
    SSL certification.
    NcCsn|dkr(|s|rd}n|jdk	r(|jj}||_||_||_||_||_|oTtjj	|�|_
|oftjj	|�|_dS)zX
        This method should only be called once, before the connection is used.
        N�
CERT_REQUIRED)r\�verify_moderZr[r^�assert_hostnamer�os�path�
expanduser�ca_certs�ca_cert_dir)r.rZr[r^rhrdrrirrr�set_certs
z VerifiedHTTPSConnection.set_certc	CsL|j�}|j}t|dd�r4||_|j�d|_|j}tjj	�t
k}|rXtjdj
t
�t�|jdkr|tt|j�t|j�d�|_|j}t|j�|_t||j|j|j|j||d�|_|jr�t|jjdd�|j�nb|jtjko�t|dd	�o�|jd	k	�r.|jj�}|j d
f��stjdj
|�t!�t"||j�p*|�|jtj#k�pD|jdk	|_$dS)Nr8rzWSystem time is way off (before {0}). This will probably lead to SSL verification errors)r]r^)r9r_r`rhriZserver_hostnamer\T)Zbinary_formZcheck_hostnameFZsubjectAltNamez�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/shazow/urllib3/issues/497 for details.))%r7r1r:r9r;r<r8�datetime�dateZtoday�RECENT_DATE�warnings�warn�formatrr\rrr]rr^rcrrZr[rhrirZgetpeercert�sslZ	CERT_NONErdr(r�_match_hostnamerbrX)r.r5ZhostnameZis_time_off�context�certrrrr>(sT



zVerifiedHTTPSConnection.connect)NNNNNNN)rr	r
r r^rhrir]rrjr>rrrrras
racCsLyt||�Wn8tk
rF}ztjd||�||_�WYdd}~XnXdS)Nz@Certificate did not match expected hostname: %s. Certificate: %s)rr�logrZ
_peer_cert)rtZasserted_hostnamer6rrrrrpsrr);Z
__future__r�rerkZloggingrer)rWrr4rr3rnr&Zsix.moves.http_clientrr,rrqZSSLErrorr�ImportError�AttributeError�
BaseExceptionr
�	NameError�	Exception�
exceptionsrrrrZpackages.ssl_match_hostnamerrZ	util.ssl_rrrrr�utilr�_collectionsrZ	getLoggerrrurUrlrm�compiler?�objectrrYrarrZUnverifiedHTTPSConnectionrrrr�<module>sR
	

&l

Zerion Mini Shell 1.0