σ β\e[c@@s\ddlmZddlZddlZddlZddlZddlZddlmZm Z ddl Z ddl m Z ddlmZddlmZyddlZejZWn3eefk rμdZdefd „ƒYZnXy eZWn'ek r d efd „ƒYZnXdd lmZmZmZm Z dd l!m"Z"m#Z#ddl$m%Z%m&Z&m'Z'm(Z(m)Z)ddl*m+Z+ddl,m-Z-ej.e/ƒZ0idd6dd6Z1ej2dddƒZ3de4fd„ƒYZ5dee4fd„ƒYZdefd„ƒYZ6de6fd„ƒYZ7d „Z8erRe6Z9e7Z6ne5Z6dS(!i(tabsolute_importN(terrorttimeouti(tsix(tHTTPConnection(t HTTPExceptiont BaseSSLErrorcB@seZRS((t__name__t __module__(((s=/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/connection.pyRstConnectionErrorcB@seZRS((RR(((s=/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/connection.pyR s(tNewConnectionErrortConnectTimeoutErrortSubjectAltNameWarningtSystemTimeWarning(tmatch_hostnametCertificateError(tresolve_cert_reqstresolve_ssl_versiontassert_fingerprinttcreate_urllib3_contexttssl_wrap_socket(t connection(tHTTPHeaderDictiPthttpi»thttpsiαiitDummyConnectioncB@seZdZRS(s-Used to detect a failed ConnectionCls import.(RRt__doc__(((s=/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/connection.pyRBsRcB@sŠeZdZedZejejdfgZe Z d„Z e d„ƒZ e jd„ƒZ d„Zd„Zd„Zd d 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., ``[]``). RicO@stjr|jddƒn|jdƒ|_tjdkrP|jddƒn|jd|jƒ|_ t j |||ŽdS(Ntstricttsource_addressiitsocket_options(ii( RtPY3tpoptNonetgetRtsyst version_infotdefault_socket_optionsRt_HTTPConnectiont__init__(tselftargstkw((s=/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/connection.pyR&ks cC@s|jjdƒS(sŸ 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). t.(t _dns_hosttrstrip(R'((s=/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/connection.pythost€scC@s ||_dS(sΧ 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'tvalue((s=/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/connection.pyR-“scC@sΎi}|jr|j|dR?theaderR.tstringish_typestchunktlen_str((s=/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/connection.pytrequest_chunkedΗs8         N(RRRtport_by_schemet default_porttsockett IPPROTO_TCPt TCP_NODELAYR$tFalset is_verifiedR&tpropertyR-tsetterR6R<R=R RU(((s=/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/connection.pyRGs    tHTTPSConnectioncB@s?eZedZdZddddejdd„Zd„Z RS(Rc K@sJtj|||d|d||||_||_||_d|_dS(NRRR(RR&tkey_filet cert_filet ssl_contextt _protocol( R'R-R0R`RaRRRbR)((s=/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/connection.pyR&σs     c C@s€|jƒ}|j|ƒ|jdkrOtdtdƒdtdƒƒ|_ntd|d|jd|j d|jƒ|_ dS(Nt ssl_versiont cert_reqsR8tkeyfiletcertfileRb( R6R<RbR RRRRR`RaR8(R'R4((s=/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/connection.pyR=s     N( RRRVRWR RdRXt_GLOBAL_DEFAULT_TIMEOUTR&R=(((s=/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/connection.pyR_ξs     tVerifiedHTTPSConnectioncB@sSeZdZdZdZdZdZdZdddddddd„Z d„Z RS(s[ Based on httplib.HTTPSConnection but wraps the socket with SSL certification. cC@s©|dkrB|s|r!d}qB|jdk rB|jj}qBn||_||_||_||_||_|o„tj j |ƒ|_ |oŸtj j |ƒ|_ dS(sX This method should only be called once, before the connection is used. t CERT_REQUIREDN( R Rbt verify_modeR`RaRetassert_hostnameRtostpatht expandusertca_certst ca_cert_dir(R'R`RaReRpRlRRq((s=/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/connection.pytset_certs        cC@sό|jƒ}|j}t|ddƒrO||_|jƒd|_|j}ntj j ƒt k}|r†t j djt ƒtƒn|jdkrΒtdt|jƒdt|jƒƒ|_n|j}t|jƒ|_td|d|jd|jd |jd |jd |d |ƒ|_|jrJt|jjd tƒ|jƒnŠ|jtj krΤt|dt!ƒ rΤ|j"t!k rΤ|jjƒ}|j#ddƒs»t j dj|ƒt$ƒnt%||j"pΝ|ƒn|jtj&kpς|jdk |_'dS(NR7isWSystem time is way off (before {0}). This will probably lead to SSL verification errorsRdReR8RfRgRpRqtserver_hostnameRbt binary_formtcheck_hostnametsubjectAltNamesκ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.)(((R6R-R9R R8R:R;R7tdatetimetdatettodayt RECENT_DATEtwarningstwarntformatR RbRRRdRReRkRR`RaRpRqRt getpeercerttTruetsslt CERT_NONER[RlR!R t_match_hostnameRjR\(R'R4thostnamet is_time_offtcontexttcert((s=/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/connection.pyR=8sT                N( RRRR ReRpRqRdRRrR=(((s=/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/connection.pyRis cC@sJyt||ƒWn2tk rE}tjd||ƒ||_‚nXdS(Ns@Certificate did not match expected hostname: %s. Certificate: %s(RRtlogRt _peer_cert(R†tasserted_hostnameR5((s=/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/connection.pyR‚€s  (:t __future__RRwtloggingRmR"RXRR2RR1R{tpackagesRtpackages.six.moves.http_clientRR%RR€tSSLErrorRt ImportErrortAttributeErrorR t BaseExceptionR t NameErrort Exceptiont exceptionsR R R R tpackages.ssl_match_hostnameRRt util.ssl_RRRRRtutilRt _collectionsRt getLoggerRR‡RVRxRztobjectRR_RiR‚tUnverifiedHTTPSConnection(((s=/tmp/pip-install-0xiv62/pip/pip/_vendor/urllib3/connection.pytsN          "(  §&l