Current File : //usr/lib/python2.7/site-packages/urllib3/connection.pyo
�
��Tc@sddlZddlZddlZddlmZddlZddlmZyddlm	Z
mZWn'ek
r�ddl
m	Z
mZnXdefd��YZyeZddlZejZWn3eefk
r�dZdefd	��YZnXy
eZWn'ek
r2d
efd��YZnXddlmZmZmZdd
lmZddl m!Z!m"Z"m#Z#m$Z$ddl%m&Z&idd6dd6Z'ej(ddd�Z)de
efd��YZ	de	fd��YZdefd��YZ*ereZ+e*ZndS(i����N(ttimeouti(tsix(tHTTPConnectiont
HTTPExceptiontDummyConnectioncBseZdZRS(s-Used to detect a failed ConnectionCls import.(t__name__t
__module__t__doc__(((s6/usr/lib/python2.7/site-packages/urllib3/connection.pyRstBaseSSLErrorcBseZRS((RR(((s6/usr/lib/python2.7/site-packages/urllib3/connection.pyRstConnectionErrorcBseZRS((RR(((s6/usr/lib/python2.7/site-packages/urllib3/connection.pyR	"s(tConnectTimeoutErrortSystemTimeWarningtSecurityWarning(tmatch_hostname(tresolve_cert_reqstresolve_ssl_versiontssl_wrap_sockettassert_fingerprint(t
connectioniPthttpi�thttpsi�RcBsZeZdZedZejejdfgZe	Z
d�Zd�Zd�Z
d�ZRS(s{
    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., ``[]``).
    RicOstjr|jdd�n|jd�|_tjdkrP|jdd�n|jd|j�|_	t
j|||�dS(Ntstricttsource_addressiitsocket_options(ii(RtPY3tpoptNonetgetRtsystversion_infotdefault_socket_optionsRt_HTTPConnectiont__init__(tselftargstkw((s6/usr/lib/python2.7/site-packages/urllib3/connection.pyR cs	cCs�i}|jr|j|d<n|jr8|j|d<ny(tj|j|jf|j|�}Wn0tk
r�t|d|j|jf��nX|S(sp Establish a socket connection and set nodelay settings on it.

        :return: New socket connection.
        RRs0Connection to %s timed out. (connect timeout=%s)(	RRRtcreate_connectionthosttportRt
SocketTimeoutR
(R!textra_kwtconn((s6/usr/lib/python2.7/site-packages/urllib3/connection.pyt	_new_connxs		"
cCs5||_t|dd�r1|j�d|_ndS(Nt_tunnel_hosti(tsocktgetattrRt_tunnelt	auto_open(R!R)((s6/usr/lib/python2.7/site-packages/urllib3/connection.pyt
_prepare_conn�s	
cCs|j�}|j|�dS(N(R*R0(R!R)((s6/usr/lib/python2.7/site-packages/urllib3/connection.pytconnect�s(RRRtport_by_schemetdefault_porttsockettIPPROTO_TCPtTCP_NODELAYRtFalsetis_verifiedR R*R0R1(((s6/usr/lib/python2.7/site-packages/urllib3/connection.pyR?s
			tHTTPSConnectioncBs6eZedZddddejd�Zd�ZRS(Rc	KsAtj|||d|d||�||_||_d|_dS(NRRR(RR tkey_filet	cert_filet	_protocol(R!R%R&R:R;RRR#((s6/usr/lib/python2.7/site-packages/urllib3/connection.pyR �s

		cCs;|j�}|j|�tj||j|j�|_dS(N(R*R0tssltwrap_socketR:R;R,(R!R)((s6/usr/lib/python2.7/site-packages/urllib3/connection.pyR1�s
N(	RRR2R3RR4t_GLOBAL_DEFAULT_TIMEOUTR R1(((s6/usr/lib/python2.7/site-packages/urllib3/connection.pyR9�s
	tVerifiedHTTPSConnectioncBsJeZdZdZdZdZdZddddddd�Zd�Z	RS(s[
    Based on httplib.HTTPSConnection but wraps the socket with
    SSL certification.
    cCs:||_||_||_||_||_||_dS(N(R:R;t	cert_reqstca_certstassert_hostnameR(R!R:R;RARBRCR((s6/usr/lib/python2.7/site-packages/urllib3/connection.pytset_cert�s					cCs�|j�}t|j�}t|j�}|j}t|dd�rm||_|j	�d|_
|j}ntj
j�tk}|r�tjdjt�t�nt||j|jd|d|jd|d|�|_|jrt|jjdt�|j�nk|tjkrp|jtk	rp|jj�}|jd	d�sWtjd
t �nt!||jpi|�n|tj"kp�|jdk	|_#dS(NR+isWSystem time is way off (before {0}). This will probably lead to SSL verification errorsRARBtserver_hostnametssl_versiontbinary_formtsubjectAltNames�Certificate 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.)(($R*RRARRFR%R-RR,R.R/R+tdatetimetdatettodaytRECENT_DATEtwarningstwarntformatRRR:R;RBRtgetpeercerttTrueR=t	CERT_NONERCR7RRR
t
CERT_REQUIREDR8(R!R)tresolved_cert_reqstresolved_ssl_versionthostnametis_time_offtcert((s6/usr/lib/python2.7/site-packages/urllib3/connection.pyR1�sB		
	
		

N(
RRRRRARBRFRRDR1(((s6/usr/lib/python2.7/site-packages/urllib3/connection.pyR@�s	(,RIRR4RR'RMtpackagesRthttp.clientRRRtImportErrorthttplibtobjectRR9R=tSSLErrorRtAttributeErrorRt
BaseExceptionR	t	NameErrort	Exceptiont
exceptionsR
RRtpackages.ssl_match_hostnameR
t	util.ssl_RRRRtutilRR2RJRLR@tUnverifiedHTTPSConnection(((s6/usr/lib/python2.7/site-packages/urllib3/connection.pyt<module>sF



"
`N