8f]ddlmZddlZddlZddlZddlZddlZddlZddlmZ ddlm Z ddl m Z ddlmZmZmZmZmZmZmZmZddlmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#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;mZ>m?Z?ddl=m@ZAddl=mBZBmCZC ddlDZDeDjEZFn#eG$r ddlHmFZFYnwxYwe&jIjJZJejKeLZMeNZOGddeNZPejQejRhZSGddePe*ZTGddeTZUdZVd Z@d!ZWdS)")absolute_importN)errortimeout)HTTPHeaderDict) BaseSSLErrorBrokenPipeErrorDummyConnectionHTTPConnection HTTPExceptionHTTPSConnectionVerifiedHTTPSConnectionport_by_scheme) ClosedPoolErrorEmptyPoolErrorHeaderParsingErrorHostChangedErrorInsecureRequestWarningLocationValueError MaxRetryErrorNewConnectionError ProtocolError ProxyErrorReadTimeoutErrorSSLError TimeoutError)six)queue)RequestMethods) HTTPResponse)is_connection_dropped)connection_requires_http_tunnel) LifoQueue)set_file_position)assert_header_parsing)Retry)CertificateError)Timeout)Url_encode_target)_normalize_host)get_host parse_url)weakref_finalizec:eZdZdZdZeZddZdZdZ dZ dZ dS) ConnectionPoola; 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. Nc|stdt||j|_||_||_dS)NzNo host specified.scheme)rr,r4hostlower _proxy_hostport)selfr5r8s /builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/pip/_vendor/urllib3/connectionpool.py__init__zConnectionPool.__init__SsJ ;$%9:: :#D=== ::<< cPt|jd|jd|jdS)Nz(host=z, port=))type__name__r5r8r9s r:__str__zConnectionPool.__str__[s*)-d)<)<)Pool reached maximum size and no more connections are allowed.z Resetting dropped connection: %s auto_openrr)r`getraAttributeErrorrrEmptyrr"rrrsr5rHgetattrrx)r9rrws r: _get_connzHTTPConnectionPool._get_conns 9==tz7=CCDD ; ; ;!$(9:: :{   z $T D    )$//  II8$) D D D JJLLLt[!,,11't~~'''s!&?A('A(c$ |j|ddS#t$rYnLtj$r;t d|j|jYnwxYw|r| dSdS)a 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. FraNzLConnection pool is full, discarding connection: %s. Connection pool size: %s) r`rdr|rFullrrwarningr5qsizerHrvs r: _put_connzHTTPConnectionPool._put_conn-s  IMM$eM , , , F    Dz    KK^  !!         JJLLLLL  s A5AA54A5cdS)U Called right before a request is made, after the socket is created. NrErvs r:_validate_connz!HTTPConnectionPool._validate_connLrOr<cdSrDrErvs r:_prepare_proxyz!HTTPConnectionPool._prepare_proxyRs r<c|tur|jSt|tr|St j|S)z:Helper that always returns a :class:`urllib3.util.Timeout`)_Defaultrcloner\r)r])r9rs r: _get_timeoutzHTTPConnectionPool._get_timeoutVsT h  <%%'' ' gw ' ' /==?? "%g.. .r<c(t|trt||d|zt|dr"|jt vrt||d|zdt |vsdt |vrt||d|zdS)zAIs the error actually a timeout? Will raise a ReadTimeout or pass!Read timed out. (read timeout=%s)errnoz timed outzdid not complete (read)N)r\ SocketTimeoutrhasattrr_blocking_errnosstr)r9errurl timeout_values r:_raise_timeoutz!HTTPConnectionPool._raise_timeoutbs c= ) ) "c>N  3  SY2B%B%B"c>N  #c(( " "&?3 D D ' ' #c>N ' ' r<c |xjdz c_||}|tj|j|_ ||n7#ttf$r#}| |||jd}~wwxYw |r|j ||fi|n|j ||fi|nM#t$rYnAt$r5}|jtjtjtjhvrYd}~nd}~wwxYw|j} t)|ddrn| dkrt+||d| z| tjur,|jt3jn|j|  |d} nR#t8$rE |} n,#t:$r}t=j|dYd}~nd}~wwxYwYnwxYwn8#ttt@f$r}| ||| d}~wwxYwt)|d d } tB"d |j#|j$|j%||| | j&| j'  tQ| j)nO#tTt8f$r;} tB+d |,|| d Yd} ~ nd} ~ wwxYw| S)a 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. r)rrrNsockrrT) buffering _http_vsn_strzHTTP/?z%s://%s:%s "%s %s %s" %s %sz$Failed to parse headers (url=%s): %s)exc_info)-rfr start_connectr)resolve_default_timeoutrurrrr rrequest_chunkedrequestr IOErrorrEPIPE ESHUTDOWN EPROTOTYPE read_timeoutr~rDEFAULT_TIMEOUTr settimeoutsocketgetdefaulttimeout getresponse TypeError BaseExceptionr raise_from SocketErrorrrrsr4r5r8statuslengthr&msgrr _absolute_url) r9rwmethodrrchunkedhttplib_request_kw timeout_objerhttplib_response http_versionhpes r: _make_requestz HTTPConnectionPool._make_request{s" Q''00 !!###6{7RSS      % % % %|,      A3dl  K K K    @$$VSGG4FGGGG VS??,>???     D   w     #/  4 & & 3 q  &#B\Qw666 $$V%=%?%?@@@@ $$\222  ,#'#3#3d#3#C#C   , , ,,'+'7'7'9'9$$$,,,N1d++++++++ ,  ,|[9      A3l  K K K   t_h??  ) K I I     #  #   !"2"6 7 7 7 7"I.    KK6""3''           sA//B#BB#'!C D D+DDF54H5 HGH G>G94H9G>>HHHHH=H88H= J""K.31K))K.cPt|j|j|j|jS)N)r4r5r8path)r*r4r5r8r)r9rs r:rz HTTPConnectionPool._absolute_urls"$+DIDIDQQQUUr<cT|jdS|jdc}|_t|dSrN)r`ri)r9old_pools r:rHzHTTPConnectionPool.closes7 9  F"i$) )))))r<c0|drdSt|\}}}|t||}|jr|st j|}n!|js|t j|krd}|||f|j|j|jfkS)zj Check if the given ``url`` is a member of the same host as this connection pool. /TNr3) startswithr-r,r8rr{r4r5)r9rr4r5r8s r: is_same_hostzHTTPConnectionPool.is_same_hosts >>#   4&c]]d  "4777D 9 T !%f--DD t~'9&'A'AAADd# TY 'JJJr<Tc t|}|j}||j}t|tst j|||j}| | dd} |r&||st|||| dr"tj t|}ntj |j}d}| }t|j|j|}|s.|}||jd}d}t+|| } ||}|| }|j|_|jduot5|dd }|r|r|||||||||| }| s|nd}|| d <|jj|f|||d | }d}n#t>$rd}d}t@tBtDtFtHtJtLf$r>}d}d }t|tHrG|jr@||r5|jr.|jjd krtOdtK|}nt|tHtLfrtK|}n`t|tDtPfr|jrtOd|}n,t|tDtBfrtGd|}|)||||tUj+d}|,|}Yd}~nd}~wwxYw|s|o|-}d}|r|.|n7#|s|o|-}d}|r|.|wwxYw|s7t^0d||||j1|||||||f|| | | | d| S|o|2}|r|j3dkr%d}d}ti|5} |)||||}n.#tl$r!|j7r|8|cYSwxYw|8|9|t^:d|||j1||||f||||| | | | d| Stw|jd}|<||j3|r |)||||}n.#tl$r!|j=r|8|cYSwxYw|8|,|t^:d||j1||||f||||| | | | d| S|S)a+ 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` N)redirectdefaultpreload_contentTrFrr)rbodyrkrrequest_method)r` connectionr_cdtjdt|}d|vpd|vS)N z[^a-z]zwrong version numberzunknown protocol)joinresplitrr6) ssl_errormessages r:%_is_ssl_error_message_from_http_proxyzIHTTPConnectionPool.urlopen.._is_ssl_error_message_from_http_proxysK((28Hc)nn6J6J6L6L#M#MNN*g5V9Kw9Vr<httpszYour 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-proxyzCannot connect to proxy.zConnection aborted.)r_pool _stacktracez1Retrying (%r) after connection broken by '%r': %s)r pool_timeout release_connrbody_posi/GET)responserzRedirecting %s -> %s)r_rassert_same_hostrrrrrz Retry-Afterz Retry: %s)>r.r4rkr\r'from_intr_r{rrrr ensure_strr+rr#rYrZcopyupdaterbr%rrrurr~rr ResponseCls from_httplibrrr rrr rr(rr incrementsysrsleeprHrrrrurlopenget_redirect_locationrr_prepare_for_method_changerraise_on_redirect drain_connsleep_for_retryrsboolis_retryraise_on_status)r9rrrrkr_rrrrrrr response_kw parsed_urldestination_schemerwrelease_this_connhttp_tunnel_requiredr clean_exitris_new_proxy_connr response_connrrrredirect_locationhas_retry_afters r:rzHTTPConnectionPool.urlopensZs^^ '. ?lG'5)) WnWxVVVG  &??+>#   1.!4!455CC.00C)> J)+=  $ /llnnG NN4- . . . %T844w %++G44K>>,>77D&6DL $ $ 6!wfd@@< ! *%9 *##D))) $11# 2   )5>DD$M-3K( )5t'4 (   HJJ   J %          5 5 5 J   1l++ <J <:9!<< <J  < J%004QKK A .>?@@ <QKKA -?@AA O(G MMOOOCCCCCCk5 p ) , $(!  %t$$$ ) , $(!  %t$$$$  %   KKCWcSV    4<  ))! "%I)G)G)I)I ! #%%(11LLNN !++FC(RV+WW    ,'')))     ! ! !  # #H - - - II,c3D E E E4<!   !!1))! "x/33MBBCC   FHO_ E E  !++FC(RV+WW    *'')))     ! ! ! MM( # # # IIk3 ' ' '4<   !!1))!  sVB+G20N#2>M.0D4M)$N#)M..N##4OQ66(R! R!U!!(V  V rD)r@rPrQrRr4r rtr!rr)rr;rxrrrrrrrrrrHrrrEr<r:rUrUqsd99vF"MK '>>>>>>>>@*%(%(%(%(N>       / / /4*25u u u u nVVV * * *KKK2xxxxxxr<rUcreZdZdZdZeZddejdddddddddddddddfdZ dZ dZ d Z fd Z xZS) HTTPSConnectionPoola 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. rNFrc tj|||||||||| | f i|| |_| |_| |_||_||_||_||_||_ ||_ dSrD) rUr;key_file cert_file cert_reqs key_passwordca_certs ca_cert_dir ssl_versionassert_hostnameassert_fingerprint)r9r5r8r[rrjrarkr_rlrmrrrrrrrrrrgs r:r;zHTTPSConnectionPool.__init__s0 #             ! ""(  &&."4r<c t|trQ||j|j|j|j|j|j|j |j |j |_ |S)z Prepare the ``connection`` for :meth:`urllib3.util.ssl_wrap_socket` and establish the tunnel if proxy is used. )rrrrrrrr) r\rset_certrrrrrrrrrrvs r: _prepare_connz!HTTPSConnectionPool._prepare_connsp d3 4 4 0 MM!... , $ 4#'#:     $/D  r<c||j|j|j|jjdkrd|_|dS)z 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. rTN) set_tunnelr7r8rbrYr4tls_in_tls_requiredconnectrvs r:rz"HTTPSConnectionPool._prepare_proxysK ($)T5GHHH :  ' ''+D $ r<c |xjdz c_td|j|j|jpd|jr|jt urtd|j}|j}|j|jj}|jj}|jd|||j j |j |j |j |jd|j}||S)zF Return a fresh :class:`http.client.HTTPSConnection`. rz)Starting new HTTPS connection (%d): %s:%s443zCCan't connect to HTTPS URL because the SSL module is not available.N)r5r8rr[rrrrE)rerrrsr5r8rtr rrYrrur[rrrrgr )r9 actual_host actual_portrws r:rxzHTTPSConnectionPool._new_conns ! 7  I I     ! T%7?%J%JU i i : !*/K*/K!t!  L0;n]*   l   !!$'''r<cRtt||t|dds||js"t jd|jztt|dddurt jdtdSdS)rrNzUnverified 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-warningsproxy_is_verifiedFzUnverified 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-warnings) superrrr~r  is_verifiedwarningswarnr5r)r9rw __class__s r:rz"HTTPSConnectionPool._validate_conns !4((77===tVT**  LLNNN  M$'+i0 '    4,d 3 3u < < M$ '      = >> conn = connection_from_url('http://google.com/') >>> r = conn.request('GET', '/') Prr8)r-rr{rrU)rkwr4r5r8s r:connection_from_urlr;sn("#FD$  1>%fb11D "499d9b999!$88T8R888r<ct||}|dr|dr |dd}|S)z? Normalize hosts for comparisons and use with sockets. []r)normalize_hostrendswith)r5r4s r:r,r,WsN $ ' 'D s c 2 2AbDz Kr<c |d}|r|-#tj$rYdSwxYw)z2Drains a queue of connections and closes each one.TFrN)r{rHrr})r`rws r:ririis_  88%8((D    ;     s.0AA)X __future__rrloggingrrrrrrrr _collectionsrrr r r r r rrr exceptionsrrrrrrrrrrrrrpackagesrpackages.six.movesrrr rr!util.connectionr" util.proxyr# util.queuer$ util.requestr% util.responser& util.retryr'util.ssl_match_hostnamer( util.timeoutr)util.urlr*r+r,r"r-r.weakreffinalizer/r|#packages.backports.weakref_finalizemovesrc getLoggerr@rrobjectrr1EAGAIN EWOULDBLOCKrrUrrrirEr<r:r<s&&&&&&  ''''''++++++((((((                    %%%%%%######""""""222222777777!!!!!!++++++000000555555!!!!!!))))))))777777))))))))FNNN'FFFEEEEEEEEF  g!! 688% % % % % V% % % RL%"34] ] ] ] ] ] ] ] @ggggg,gggT9998$     s C CC