Eu\dc@@sddlmZddlZddlZddlZddlZddlZddlZddlmZ ddlm Z ddl m Z mZmZmZmZmZmZmZddlmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"ddl#m$Z$dd l%m&Z&dd l'm(Z(dd l)m*Z*dd l+m,Z,dd l-m.Z.ddl/m0Z0ddl1m2Z2ddl3m4Z4ddl5m6Z6ddl7m8Z8ddl9m:Z:ddl;m<Z<m=Z=ddl;m>Z?ddl;m@Z@mAZAe$jBjCZCejDeEZFeGZHdeGfdYZIejJejKhZLdeIe(fdYZMdeMfdYZNdZOdZ>dS(i(tabsolute_importN(terror(ttimeouti(t BaseSSLErrortBrokenPipeErrortDummyConnectiontHTTPConnectiont HTTPExceptiontHTTPSConnectiontVerifiedHTTPSConnectiontport_by_scheme( tClosedPoolErrortEmptyPoolErrortHeaderParsingErrortHostChangedErrortInsecureRequestWarningtLocationValueErrort MaxRetryErrortNewConnectionErrort ProtocolErrort ProxyErrortReadTimeoutErrortSSLErrort TimeoutError(tsix(tqueue(tRequestMethods(t HTTPResponse(tis_connection_dropped(tconnection_requires_http_tunnel(t LifoQueue(tset_file_position(tassert_header_parsing(tRetry(tCertificateError(tTimeout(tUrlt_encode_target(t_normalize_host(tget_hostt parse_urltConnectionPoolcB@sJeZdZdZeZddZdZdZ dZ dZ RS(s; Base class for all connection pools, such as :class:`.HTTPConnectionPool` and :class:`.HTTPSConnectionPool`. .. note:: ConnectionPool.urlopen() does not normalize or percent-encode target URIs which is useful if your target server doesn't support percent-encoded target URIs. cC@sI|stdnt|d|j|_|j|_||_dS(NsNo host specified.tscheme(RR&R*thosttlowert _proxy_hosttport(tselfR+R.((so/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connectionpool.pyt__init__Ks cC@s dt|j|j|jfS(Ns%s(host=%r, port=%r)(ttypet__name__R+R.(R/((so/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connectionpool.pyt__str__SscC@s|S(N((R/((so/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connectionpool.pyt __enter__VscC@s|jtS(N(tclosetFalse(R/texc_typetexc_valtexc_tb((so/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connectionpool.pyt__exit__Ys cC@sdS(sD Close all pooled connections and disable the pool. N((R/((so/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connectionpool.pyR5^sN( R2t __module__t__doc__tNoneR*RtQueueClsR0R3R4R:R5(((so/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connectionpool.pyR)=s     tHTTPConnectionPoolc B@seZdZdZeZeZde e j de dddddd Z dZ ddZdZdZdZd Zd Zee d Zd Zd ZdZdddeeedde dd ZRS(s: Thread-safe connection pool for one host. :param host: Host used for this HTTP Connection (e.g. "localhost"), passed into :class:`http.client.HTTPConnection`. :param port: Port used for this HTTP Connection (None is equivalent to 80), passed into :class:`http.client.HTTPConnection`. :param strict: Causes BadStatusLine to be raised if the status line can't be parsed as a valid HTTP/1.0 or 1.1 status line, passed into :class:`http.client.HTTPConnection`. .. note:: Only works in Python 2. This parameter is ignored in Python 3. :param timeout: Socket timeout in seconds for each individual connection. This can be a float or integer, which sets the timeout for the HTTP request, or an instance of :class:`urllib3.util.Timeout` which gives you more fine-grained control over request timeouts. After the constructor has been parsed, this is always a `urllib3.util.Timeout` object. :param maxsize: Number of connections to save that can be reused. More than 1 is useful in multithreaded situations. If ``block`` is set to False, more connections will be created but they will not be saved once they've been used. :param block: If set to True, no more than ``maxsize`` connections will be used at a time. When no free connections are available, the call will block until a connection has been released. This is a useful side effect for particular multithreaded situations where one does not want to use more than maxsize connections per host to prevent flooding. :param headers: Headers to include with all requests, unless other headers are given explicitly. :param retries: Retry configuration to use by default with requests in this pool. :param _proxy: Parsed proxy URL, should not be used directly, instead, see :class:`urllib3.ProxyManager` :param _proxy_headers: A dictionary with proxy headers, should not be used directly, instead, see :class:`urllib3.ProxyManager` :param \**conn_kw: Additional parameters are used to create fresh :class:`urllib3.connection.HTTPConnection`, :class:`urllib3.connection.HTTPSConnection` instances. thttpic K@s8tj|||tj||||_t|tsMtj|}n|dkretj }n||_ ||_ |j ||_ ||_| |_| pi|_| |_x$t|D]} |j jdqWd|_d|_| |_|jr4|jjdg|j|jd<|j|jdtpooltblockRBt proxy_headersRCtxrangetputtnum_connectionst num_requeststconn_kwt setdefault(R/R+R.RDRtmaxsizeRJtheadersRHt_proxyt_proxy_headerst _proxy_configRPt_((so/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connectionpool.pyR0s.            c C@sq|jd7_tjd|j|j|jp0d|jd|jd|jd|jjd|j|j }|S(s9 Return a fresh :class:`HTTPConnection`. is(Starting new HTTP connection (%d): %s:%st80R+R.RRD( RNtlogtdebugR+R.t ConnectionClsRtconnect_timeoutRDRP(R/tconn((so/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connectionpool.pyt _new_conns     cC@sd }y"|jjd|jd|}WnNtk rJt|dn/tjk rx|jryt|dqynX|rt |rt j d|j |j t|dddkrd }qn|p|jS( s Get a connection. Will return a pooled connection if one is available. If no connections are available and :prop:`.block` is ``False``, then a fresh connection is returned. :param timeout: Seconds to wait before giving up and raising :class:`urllib3.exceptions.EmptyPoolError` if the pool is empty and :prop:`.block` is ``True``. RJRsPool is closed.s>Pool reached maximum size and no more connections are allowed.s Resetting dropped connection: %st auto_openiiN(R=RItgetRJtAttributeErrorR RtEmptyR RRYRZR+R5tgetattrR^(R/RR]((so/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connectionpool.pyt _get_conns" "     cC@s{y|jj|dtdSWnCtk r1n3tjk rctjd|j|jj nX|rw|j ndS(s Put a connection back into the pool. :param conn: Connection object for the current host and port as returned by :meth:`._new_conn` or :meth:`._get_conn`. If the pool is already full, the connection is closed and discarded because we exceeded maxsize. If connections are discarded frequently, then maxsize should be increased. If the pool is closed, then the connection will be closed and discarded. RJNsLConnection pool is full, discarding connection: %s. Connection pool size: %s( RIRMR6RaRtFullRYtwarningR+tqsizeR5(R/R]((so/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connectionpool.pyt _put_conns cC@sdS(sU Called right before a request is made, after the socket is created. N((R/R]((so/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connectionpool.pyt_validate_conn:scC@sdS(N((R/R]((so/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connectionpool.pyt_prepare_proxy@scC@sC|tkr|jjSt|tr2|jStj|SdS(s:Helper that always returns a :class:`urllib3.util.Timeout`N(t_DefaultRtcloneRER#RF(R/R((so/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connectionpool.pyt _get_timeoutDs    cC@st|tr(t||d|nt|dr_|jtkr_t||d|ndt|ksdt|krt||d|ndS(sAIs the error actually a timeout? Will raise a ReadTimeout or passs!Read timed out. (read timeout=%s)terrnos timed outsdid not complete (read)N(REt SocketTimeoutRthasattrRnt_blocking_errnoststr(R/terrturlt timeout_value((so/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connectionpool.pyt_raise_timeoutPs c K@s|jd7_|j|}|jtj|j|_y|j|Wn;tt fk r}|j d|d|d|jnXy3|r|j |||n|j |||WnJt k rn:tk r }|jtjtjtjhkr q nX|j} t|ddr| dkrLt||d| n| tjkrt|jjtjq|jj| nydy|jdt} WnGtk ry|j} Wqtk r}t j!|dqXnXWn;tt t"fk r(}|j d|d|d| nXt|d d } t#j$d |j%|j&|j'||| | j(| j) yt*| j+Wn;t,tfk r} t#j-d |j.|| d tnX| S(s Perform a request on a given urllib connection object taken from our pool. :param conn: a connection from one of our connection pools :param timeout: Socket timeout in seconds for the request. This can be a float or integer, which will set the same timeout value for the socket connect and the socket read, or an instance of :class:`urllib3.util.Timeout`, which gives you more fine-grained control over your timeouts. iRsRtRutsockis!Read timed out. (read timeout=%s)t bufferingt _http_vsn_strsHTTP/?s%s://%s:%s "%s %s %s" %s %ss$Failed to parse headers (url=%s): %stexc_infoN(/RORmt start_connectR#tresolve_default_timeoutR\RRiRoRRvtrequest_chunkedtrequestRtIOErrorRntEPIPEt ESHUTDOWNt EPROTOTYPEt read_timeoutRcR=RtDEFAULT_TIMEOUTRwt settimeouttsockettgetdefaulttimeoutt getresponsetTruet TypeErrort BaseExceptionRt raise_fromt SocketErrorRYRZR*R+R.tstatustlengthR tmsgR Rft _absolute_url( R/R]tmethodRtRtchunkedthttplib_request_kwt timeout_objteRthttplib_responset http_versionthpe((so/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connectionpool.pyt _make_requestisx         c C@s+td|jd|jd|jd|jS(NR*R+R.tpath(R$R*R+R.Rt(R/R((so/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connectionpool.pyRscC@sw|jdkrdS|jd}|_y6x/trZ|jdt}|r,|jq,q,WWntjk rrnXdS(sD Close all pooled connections and disable the pool. NRJ(RIR=RR`R6R5RRb(R/told_poolR]((so/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connectionpool.pyR5s cC@s|jdrtSt|\}}}|dk rIt|d|}n|jrk| rktj|}n(|j r|tj|krd}n|||f|j|j |jfkS(sj Check if the given ``url`` is a member of the same host as this connection pool. t/R*N( t startswithRR'R=R&R.R R`R*R+(R/RtR*R+R.((so/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connectionpool.pyt is_same_hosts  c K@st|}|j}|dkr-|j}nt|ts]tj|d|d|j}n| dkr~| jdt } n|r|j | rt |||n|j drt jt|}nt j|j}d}| }t|j|j|}|s+|j}|j|jnd}t}t|| } zRy|j|}|jd| }|j|_|jdk ot|dd }|r|r|j|n|j|||d|d|d|d | }| s|nd}|| d <|j j!|d |d |d || }t }Wnft"k rPt }t}nGt#t$t%t&t't(t)fk r}t}d}t|t'r|jr||r|jr|jjdkrt*dt(|}n{t|t't)frt(|}nWt|t%t+fr.|jr.t*d|}n't|t%t$frUt&d|}n|j,||d|d|dt-j.d}|j/|}nXWd|s|o|j0}t }n|r|j1|nX|s/t2j3d||||j4|||||||d|d| d| d | d| | S|o>|j5}|r"|j6dkr_d}ny"|j,||d|d|}Wn+t7k r|j8r|j9n|SX|j9|j:|t2j;d|||j4||||d |d|d |d|d| d| d | d| | St<|jjd!}|j=||j6|ry"|j,||d|d|}Wn+t7k r|j>r|j9n|SX|j9|j/|t2j;d"||j4||||d |d|d |d|d| d| d | d| | S|S(#s+ Get a connection from the pool and perform an HTTP request. This is the lowest level call for making a request, so you'll need to specify all the raw details. .. note:: More commonly, it's appropriate to use a convenience method provided by :class:`.RequestMethods`, such as :meth:`request`. .. note:: `release_conn` will only behave as expected if `preload_content=False` because we want to make `preload_content=False` the default behaviour someday soon without breaking backwards compatibility. :param method: HTTP request method (such as GET, POST, PUT, etc.) :param url: The URL to perform the request on. :param body: Data to send in the request body, either :class:`str`, :class:`bytes`, an iterable of :class:`str`/:class:`bytes`, or a file-like object. :param headers: Dictionary of custom headers to send, such as User-Agent, If-None-Match, etc. If None, pool headers are used. If provided, these headers completely replace any pool-specific headers. :param retries: Configure the number of retries to allow before raising a :class:`~urllib3.exceptions.MaxRetryError` exception. Pass ``None`` to retry until you receive a response. Pass a :class:`~urllib3.util.retry.Retry` object for fine-grained control over different types of retries. Pass an integer number to retry connection errors that many times, but no other types of errors. Pass zero to never retry. If ``False``, then retries are disabled and any exception is raised immediately. Also, instead of raising a MaxRetryError on redirects, the redirect response will be returned. :type retries: :class:`~urllib3.util.retry.Retry`, False, or an int. :param redirect: If True, automatically handle redirects (status codes 301, 302, 303, 307, 308). Each redirect counts as a retry. Disabling retries will disable redirect, too. :param assert_same_host: If ``True``, will make sure that the host of the pool requests is consistent else will raise HostChangedError. When ``False``, you can use the pool on an HTTP proxy and request foreign hosts. :param timeout: If specified, overrides the default timeout for this one request. It may be a float (in seconds) or an instance of :class:`urllib3.util.Timeout`. :param pool_timeout: If set and the pool is set to block=True, then this method will block for ``pool_timeout`` seconds and raise EmptyPoolError if no connection is available within the time period. :param release_conn: If False, then the urlopen call will not release the connection back into the pool once a response is received (but will release if you read the entire contents of the response such as when `preload_content=True`). This is useful if you're not preloading the response's content immediately. You will need to call ``r.release_conn()`` on the response ``r`` to return the connection back into the pool. If None, it takes the value of ``response_kw.get('preload_content', True)``. :param chunked: If True, urllib3 will send the body using chunked transfer encoding. Otherwise, urllib3 will send the body using the standard content-length form. Defaults to False. :param int body_pos: Position to seek to in file-like body in the event of a retry or redirect. Typically this won't need to be set because urllib3 will auto-populate the value when needed. :param \**response_kw: Additional parameters are passed to :meth:`urllib3.response.HTTPResponse.from_httplib` tredirecttdefaulttpreload_contentRRRwtbodyRSRtrequest_methodRIt connectionRHcS@s=djtjdt|j}d|kp<d|kS(Nt s[^a-z]swrong version numbersunknown protocol(tjointretsplitRrR,(t ssl_errortmessage((so/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connectionpool.pyt%_is_ssl_error_message_from_http_proxys'thttpssYour proxy appears to only use HTTP and not HTTPS, try changing your proxy URL to be HTTP. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#https-proxy-error-http-proxysCannot connect to proxy.sConnection aborted.Rt_poolt _stacktraceiNs1Retrying (%r) after connection broken by '%r': %st pool_timeoutt release_conntbody_posi/tGETtresponsesRedirecting %s -> %stassert_same_hosts Retry-Afters Retry: %s(?R(R*R=RSRER!tfrom_intRHR`RRRRRt ensure_strR%RtRRBRCtcopytupdateRKR6RRmRdR\RRcRjRt ResponseClst from_httplibR RRRRRRR"RRt incrementtsysRztsleepR5RhRYRfturlopentget_redirect_locationRRtraise_on_redirectt drain_conntsleep_for_retryRZtbooltis_retrytraise_on_status(R/RRtRRSRHRRRRRRRt response_kwt parsed_urltdestination_schemeR]trelease_this_connthttp_tunnel_requiredRst clean_exitRtis_new_proxy_connRt response_connRRRtredirect_locationthas_retry_after((so/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connectionpool.pyR s>m    !                (   "     "     N(R2R;R<R*RR[RRR=R6R#RR0R^RdRhRiRjRmRvRkRRR5RRR(((so/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connectionpool.pyR?isF: *  '    v   tHTTPSConnectionPoolcB@seZdZdZeZdeej deddddddddddddddZ dZ dZ dZ dZRS( s Same as :class:`.HTTPConnectionPool`, but HTTPS. :class:`.HTTPSConnection` uses one of ``assert_fingerprint``, ``assert_hostname`` and ``host`` in this order to verify connections. If ``assert_hostname`` is False, no verification is done. The ``key_file``, ``cert_file``, ``cert_reqs``, ``ca_certs``, ``ca_cert_dir``, ``ssl_version``, ``key_password`` are only used if :mod:`ssl` is available and are fed into :meth:`urllib3.util.ssl_wrap_socket` to upgrade the connection socket into an SSL socket. Ric K@stj|||||||||| | | | |_| |_| |_||_||_||_||_||_ ||_ dS(N( R?R0tkey_filet cert_filet cert_reqst key_passwordtca_certst ca_cert_dirt ssl_versiontassert_hostnametassert_fingerprint(R/R+R.RDRRRRJRSRHRTRURRRRRRRRRRP((so/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connectionpool.pyR0s,        cC@stt|trp|jd|jd|jd|jd|jd|jd|jd|j d|j |j |_ n|S( s Prepare the ``connection`` for :meth:`urllib3.util.ssl_wrap_socket` and establish the tunnel if proxy is used. RRRRRRRR( RER tset_certRRRRRRRRR(R/R]((so/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connectionpool.pyt _prepare_conns         cC@sH|j|j|j|j|jjdkr:t|_n|jdS(s Establishes a tunnel connection through HTTP CONNECT. Tunnel connection is established early because otherwise httplib would improperly set Host: header to proxy's IP:port. RN( t set_tunnelR-R.RKRBR*Rttls_in_tls_requiredtconnect(R/R]((so/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connectionpool.pyRjs cC@s|jd7_tjd|j|j|jp0d|j sM|jtkr\tdn|j}|j}|jd k r|jj}|jj}n|jd|d|d|j j d|j d |j d |jd |j|j}|j|S( sF Return a fresh :class:`http.client.HTTPSConnection`. is)Starting new HTTPS connection (%d): %s:%st443sCCan't connect to HTTPS URL because the SSL module is not available.R+R.RRDRRRN(RNRYRZR+R.R[RRRBR=RR\RDRRRRPR(R/t actual_hostt actual_portR]((so/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connectionpool.pyR^s0          cC@stt|j|t|dds5|jn|jsXtjd|j t nt|ddt krtjdt ndS(sU Called right before a request is made, after the socket is created. RwsUnverified HTTPS request is being made to host '%s'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warningstproxy_is_verifiedsUnverified HTTPS connection done to an HTTPS proxy. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warningsN( tsuperRRiRcR=Rt is_verifiedtwarningstwarnR+RR6(R/R]((so/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connectionpool.pyRi s   N(R2R;R<R*RR[R=R6R#RR0RRjR^Ri(((so/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connectionpool.pyRs2     $cK@sct|\}}}|p*tj|d}|dkrLt|d||St|d||SdS(s Given a url, return an :class:`.ConnectionPool` instance of its host. This is a shortcut for not having to parse out the scheme, host, and port of the url before creating an :class:`.ConnectionPool` instance. :param url: Absolute URL string that must include the scheme. Port is optional. :param \**kw: Passes additional parameters to the constructor of the appropriate :class:`.ConnectionPool`. Useful for specifying things like timeout, maxsize, headers, etc. Example:: >>> conn = connection_from_url('http://google.com/') >>> r = conn.request('GET', '/') iPRR.N(R'R R`RR?(RttkwR*R+R.((so/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connectionpool.pytconnection_from_url+s  cC@sAt||}|jdr=|jdr=|dd!}n|S(s? Normalize hosts for comparisons and use with sockets. t[t]ii(tnormalize_hostRtendswith(R+R*((so/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connectionpool.pyR&Gs(Pt __future__RRntloggingRRRRRRRRoRRRRRRRR R t exceptionsR R R RRRRRRRRRRtpackagesRtpackages.six.movesRR~RRRtutil.connectionRt util.proxyRt util.queueRt util.requestRt util.responseR t util.retryR!tutil.ssl_match_hostnameR"t util.timeoutR#tutil.urlR$R%R&RR'R(tmovesRLt getLoggerR2RYtobjectRkR)tEAGAINt EWOULDBLOCKRqR?RR(((so/private/var/folders/49/mc35vj0j30g7w0ryjvyy2vz80000gs/T/pip-target-MP7kiJ/lib/python/urllib3/connectionpool.pytsJ      : X  )