Eu\dc@@sddlmZddlZddlZddlZddlZddlZddlZddlmZ ddlm Z ddl m Z ddlmZddlmZdd lmZyddlZejZWn3eefk rdZd efd YZnXy eZWn'ek r:d efd YZnXy eZWn'ek rndefdYZnXddlm Z ddl!m"Z"ddl#m$Z$m%Z%m&Z&m'Z'ddl(m)Z)m*Z*m+Z+ddl,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2ddl3m4Z4m5Z5ej6e7Z8idd6dd6Z9ej:dddZ;ej<dZ=dee>fdYZdefdYZ?d Z@d!ZAd"e>fd#YZBeseBZ?ne?ZCdS($i(tabsolute_importN(terror(ttimeouti(tsix(tHTTPConnection(t HTTPException(tcreate_proxy_ssl_contextt BaseSSLErrorcB@seZRS((t__name__t __module__(((sk/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connection.pyRstConnectionErrorcB@seZRS((RR (((sk/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connection.pyR !stBrokenPipeErrorcB@seZRS((RR (((sk/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connection.pyR *s(tHTTPHeaderDict(t __version__(tConnectTimeoutErrortNewConnectionErrortSubjectAltNameWarningtSystemTimeWarning(t SKIP_HEADERtSKIPPABLE_HEADERSt connection(tassert_fingerprinttcreate_urllib3_contextt is_ipaddresstresolve_cert_reqstresolve_ssl_versiontssl_wrap_socket(tCertificateErrortmatch_hostnameiPthttpithttpsis[^-!#$%&'*+.^_`|~0-9a-zA-Z]RcB@seZdZedZejejdfgZe Z dZ dZ edZejdZdZdZdZd Zd Zd Zddd Zddd ZRS(s5 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., ``[]``). RicO@stjs|jddn|jd|_|jd|j|_|jdd|_|jdd|_ t j |||dS(Ntstricttsource_addresstsocket_optionstproxyt proxy_config( RtPY2tpoptNonetgetR tdefault_socket_optionsR!R"R#t_HTTPConnectiont__init__(tselftargstkw((sk/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connection.pyR*ss cC@s|jjdS(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+((sk/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connection.pythostscC@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((sk/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connection.pyR1scC@si}|jr|j|dss+urllib3.util.SKIP_HEADER only supports '%s's', 'N( tanyR)t putheaderRt ensure_strtlowerRRFtjointmapRNttitletsorted(R+theadertvalues((sk/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connection.pyRRs cC@st|dddk r.|jj|jn|dkrCi}n |j}dd|Dkrut|ds user-agentcs@s$|]}tj|jVqdS(N(RRSRT(ROtk((sk/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connection.pys ss User-Agenttbodytheaders( R<R&R>t settimeoutRtcopyt_get_default_user_agenttsuperRtrequest(R+RIRJR\R]((sk/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connection.pyRbs   cC@s|p i}tg|D]}tj|j^q}d|k}d|k}|j||d|d|d|kr|jdtnx*|jD]\} } |j| | qWd|kr|jdd n|j|dk rtj t f} t || r|f}nx|D]} | s6q$nt | t sW| j d } ntt| d } t| j }|d 7}|| 7}|d 7}|j|q$Wn|jd dS(s Alternative to the common request method, which sends the body with chunked encoding and not as one block saccept-encodingR1tskip_accept_encodingt skip_hosts user-agents User-Agentstransfer-encodingsTransfer-Encodingtchunkedtutf8is s0 N(tsetRRSRTRHRRR`titemst endheadersR&t string_typestbytesRMtencodethextlent bytearraytsend(R+RIRJR\R]R[t header_keysRcRdRYR2tstringish_typestchunktlen_strtto_send((sk/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connection.pytrequest_chunkeds: .           N(RR t__doc__tport_by_schemet default_porttsockett IPPROTO_TCPt TCP_NODELAYR(tFalset is_verifiedR&tproxy_is_verifiedR*tpropertyR1tsetterR:R=RARBRHRRRbRv(((sk/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connection.pyRLs        tHTTPSConnectionc B@seZdZedZdZdZdZdZ dZ dZ e Z dddddejdddZdddddddddd ZdZdZRS(s Many of the parameters to this constructor are passed to the underlying SSL socket by means of :py:func:`urllib3.util.ssl_wrap_socket`. Rc K@s\tj|||d|d|| ||_||_||_||_| |_d|_dS(NRRR(RR*tkey_filet cert_filet key_passwordt ssl_contexttserver_hostnamet _protocol( R+R1R4RRRRRRRR-((sk/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connection.pyR*.s"     c C@s|dkr9|jdk r*|jj}q9td}n||_||_||_||_||_||_ |ot j j ||_ |ot j j ||_| |_dS(sX This method should only be called once, before the connection is used. N(R&Rt verify_modeRRRt cert_reqsRtassert_hostnameRtostpatht expandusertca_certst ca_cert_dirt ca_cert_data( R+RRRRRRRRR((sk/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connection.pytset_certHs       c C@s|j|_}|j}t}|jrx|jrY|j|||_}t}n|jd|_ |j }n|}|j dk r|j }nt jjtk}|rtjdjttnt}|jdkrt}tdt|jdt|j|_n|j}t|j|_|j rs|j rs|j rs|rst|drs|j nt!d|d|j"d|j#d |j$d |jd |jd |jd |d|d| |_|r8|jdkr8t|jdr8|jj%ddhkr8tjd|j|jj%ft&n|j'rct'|jj(dt|j'n|jt)j*krt+|dt r|j,tk r|jj(}|j-ddstjdj|t.nt/||j,p|n|jt)j0kp |j'dk |_1dS(NisWSystem time is way off (before {0}). This will probably lead to SSL verification errorst ssl_versionRtload_default_certsR>tkeyfiletcertfileRRRRRRt tls_in_tlstversiontTLSv1sTLSv1.1sNegotiating 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't binary_formtcheck_hostnametsubjectAltNamesCertificate 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.)((2R:R>R1R}R=ttls_in_tls_requiredt_connect_tls_proxytTrueR?R@R;RR&tdatetimetdatettodayt RECENT_DATEtwarningstwarntformatRRRRRRRRRRRthasattrRRRRRRtDeprecationWarningRt getpeercerttsslt CERT_NONER<RR'Rt_match_hostnamet CERT_REQUIREDR~( R+R8thostnameRRt is_time_offtdefault_ssl_contexttcontexttcert((sk/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connection.pyRBis                        c C@s|j}|j}|r1td|d|d|St|j|j|j|j|j}td|d|jd|jd|jd|d|}|j t j krt |dt  r|j}|jdd stjd j|tnt||n|j t jk|_|S( sY Establish a TLS connection to the proxy using the provided SSL context. R>RRRRRRRsCertificate 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.)((R#RRRRRRRRRRRR<R}RR'RRRRRRR(R+RR8R#RRzR((sk/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connection.pyRs>         N(RR RwRxRyR&RRRRRRR}RRzt_GLOBAL_DEFAULT_TIMEOUTR*RRBR(((sk/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connection.pyRs8    vcC@sn|jd}t|r$|}nyt||Wn2tk ri}tjd||||_nXdS(Nsu[]s@Certificate did not match expected hostname: %s. Certificate: %s(tstripRRRtlogtwarningt _peer_cert(Rtasserted_hostnametstripped_hostnameR9((sk/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connection.pyRs   cC@sdtS(Nspython-urllib3/%s(R (((sk/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connection.pyR`.stDummyConnectioncB@seZdZRS(s-Used to detect a failed ConnectionCls import.(RR Rw(((sk/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connection.pyR2s(Dt __future__RRtloggingRtreRzRRR6RR5tpackagesRtpackages.six.moves.http_clientRR)Rt util.proxyRRtSSLErrorRt ImportErrortAttributeErrorR&t BaseExceptionR t NameErrort ExceptionR t _collectionsR t_versionR t exceptionsRRRRtutilRRRt util.ssl_RRRRRRtutil.ssl_match_hostnameRRt getLoggerRRRxRRtcompileRDtobjectRRR`RtVerifiedHTTPSConnection(((sk/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connection.pytsX            ".