Hacked By AnonymousFox

Current Path : /usr/lib/python3.6/site-packages/urllib3/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/urllib3/__pycache__/connection.cpython-36.pyc

3

h��f
8�@s�ddlmZddlZddlZddlZddlZddlZddlmZm	Z
ddlZddlm
Z
ddlmZddlmZyddlZejZWn,eefk
r�dZGdd	�d	e�ZYnXyeZWn$ek
r�Gd
d�de�ZYnXddlmZmZmZmZdd
l m!Z!m"Z"ddl#m$Z$m%Z%m&Z&m'Z'm(Z(ddl)m*Z*ddl+m,Z,ej-e.�Z/ddd�Z0ej1ddd�Z2ej3d�Z4Gdd�de5�Z6Gdd�dee5�ZGdd�de�Z7Gdd�de7�Z8dd �Z9e�r�e7Z:e8Z7ne6Z7dS)!�)�absolute_importN)�error�timeout�)�six)�HTTPConnection)�
HTTPExceptionc@seZdZdS)�BaseSSLErrorN)�__name__�
__module__�__qualname__�r
r
� /usr/lib/python3.6/connection.pyr	sr	c@seZdZdS)�ConnectionErrorN)r
rrr
r
r
rrsr)�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)r
rr�__doc__r
r
r
rr!Dsr!c@sxeZdZdZedZejejdfgZ	dZ
dd�Zedd��Z
e
jd	d��Z
d
d�Zdd
�Zdd�Zdd�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.
      - ``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., ``[]``).
    rrFcOsDtjr|jdd�|jd�|_|jd|j�|_tj|f|�|�dS)N�strict�source_address�socket_options)	rZPY3�pop�getr$�default_socket_optionsr%�_HTTPConnection�__init__)�self�args�kwr
r
rr*js
zHTTPConnection.__init__cCs|jjd�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)r+r
r
r�hostwszHTTPConnection.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)r/)r+�valuer
r
rr1�scCs�i}|jr|j|d<|jr$|j|d<ytj|j|jf|jf|�}Wnftk
rz}zt|d|j	|jf��WYdd}~Xn0t
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)Nz(Failed to establish a new connection: %s)r$r%rZcreate_connectionr/�portr�
SocketTimeoutrr1�SocketErrorr)r+Zextra_kw�conn�er
r
r�	_new_conn�s 

 zHTTPConnection._new_conncCs||_|jr|j�d|_dS)Nr)�sock�_tunnel_host�_tunnel�	auto_open)r+r6r
r
r�
_prepare_conn�szHTTPConnection._prepare_conncCs|j�}|j|�dS)N)r8r=)r+r6r
r
r�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�matchr
r
rrC�s
zHTTPConnection.putrequestNcCst|dk	r|ni�}d|k}d|k}|j||||d�x |j�D]\}}|j||�q@Wd|krl|jdd�|j�|dk	�rtjtf}	t||	�r�|f}xh|D]`}
|
s�q�t|
t�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�utf8�zutf-8s
s0

)
rrC�itemsZ	putheaderZ
endheadersrZstring_types�bytes�
isinstance�encode�hex�len�send)r+rDrEZbodyZheadersrHrI�headerr2Zstringish_types�chunkZlen_strr
r
r�request_chunked�s8






zHTTPConnection.request_chunked)NN)r
rrr"�port_by_scheme�default_port�socketZIPPROTO_TCPZTCP_NODELAYr(�is_verifiedr*�propertyr1�setterr8r=r>rCrUr
r
r
rrIs

rc@s:eZdZedZdZddddejddfdd�Zdd�Z	dS)�HTTPSConnectionrNc	
Ks>tj|||f||d�|	��||_||_||_||_d|_dS)N)r#rr)rr*�key_file�	cert_file�ssl_context�server_hostnameZ	_protocol)
r+r1r3r]r^r#rr_r`r-r
r
rr*�szHTTPSConnection.__init__cCsR|j�}|j|�|jdkr2ttd�td�d�|_t||j|j|j|j	d�|_
dS)N)�ssl_version�	cert_reqs)r9�keyfile�certfiler_r`)r8r=r_rrrrr]r^r`r9)r+r6r
r
rr>s

zHTTPSConnection.connect)
r
rrrVrWrarXZ_GLOBAL_DEFAULT_TIMEOUTr*r>r
r
r
rr\�sr\c@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_moder]r^rb�assert_hostnamer�os�path�
expanduser�ca_certs�ca_cert_dir)r+r]r^rbrlrhrrmr
r
r�set_cert s
z VerifiedHTTPSConnection.set_certc	CsZ|j�}|j}|jr.||_|j�d|_|j}|}|jdk	rB|j}tjj	�t
k}|rftj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�|j dk	�r<|jj�}|j!d	f��s*tjd
j
|�t"�t#||j �p8|�|jtj$k�pR|jdk	|_%dS)NrzWSystem time is way off (before {0}). This will probably lead to SSL verification errors)rarb)r9rcrdrlrmr`r_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.))&r8r1r:r9r;r<r`�datetime�dateZtoday�RECENT_DATE�warnings�warn�formatrr_rrrarrbrgrr]r^rlrmrZgetpeercert�sslZ	CERT_NONE�getattrrhr'r�_match_hostnamerfrY)r+r6Zhostnamer`Zis_time_off�context�certr
r
rr>9sZ




zVerifiedHTTPSConnection.connect)NNNNNNN)r
rrr"rbrlrmrarrnr>r
r
r
rres
recCsLyt||�Wn8tk
rF}ztjd||�||_�WYdd}~XnXdS)Nz@Certificate did not match expected hostname: %s. Certificate: %s)rr�logrZ
_peer_cert)ryZasserted_hostnamer7r
r
rrw�srw);Z
__future__r�reroZloggingrirXrr5rr4rrZpackagesrZpackages.six.moves.http_clientrr)rruZSSLErrorr	�ImportError�AttributeError�
BaseExceptionr�	NameError�	Exception�
exceptionsrrrrZpackages.ssl_match_hostnamerrZ	util.ssl_rrrrr�utilr�_collectionsrZ	getLoggerr
rzrVrprq�compiler?�objectr!r\rerwZUnverifiedHTTPSConnectionr
r
r
r�<module>sP
	

%(m

Hacked By AnonymousFox1.0, Coded By AnonymousFox