mf <ddlmZddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z m Z mZmZmZmZmZmZddlmZmZmZmZmZmZmZmZmZmZmZm 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.m/Z/ddl0m1Z1ddl2m3Z3ddl4m5Z5ddl6m7Z7ddl8m9Z9ddl:m;Z;mddl:m?Z?m@Z@e#jAjBZBejCeDZEeFZGGddeFZHejIejJhZKGddeHe)ZLGddeLZMdZNdZ=dS))absolute_importN)errortimeout) BaseSSLErrorBrokenPipeErrorDummyConnectionHTTPConnection HTTPExceptionHTTPSConnectionVerifiedHTTPSConnectionport_by_scheme) ClosedPoolErrorEmptyPoolErrorHeaderParsingErrorHostChangedErrorInsecureRequestWarningLocationValueError MaxRetryErrorNewConnectionError ProtocolError ProxyErrorReadTimeoutErrorSSLError TimeoutError)six)queue)CertificateError)RequestMethods) HTTPResponse)is_connection_dropped)connection_requires_http_tunnel) LifoQueue)set_file_position)assert_header_parsing)Retry)Timeout)Url_encode_target)_normalize_host)get_host parse_urlc: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+r2hostlower _proxy_hostport)selfr3r6s M/opt/imunify360/venv/lib64/python3.11/site-packages/urllib3/connectionpool.py__init__zConnectionPool.__init__JsJ ;$%9:: :#D=== ::<< cPt|jd|jd|jdS)Nz(host=z, port=))type__name__r3r6r7s r8__str__zConnectionPool.__str__Rs*)-d)<)<) __module__ __qualname____doc__r2r$QueueClsr9r@rDrJrFrCr:r8r/r/<s}FHTTT      r:r/c eZdZdZdZeZeZdde j dddddddf dZ dZ ddZ d Zd Zd Zd Zd ZedfdZdZdZdZdddddeddddf dZdS)HTTPConnectionPoola: 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. httpNFrc  vt|||tj||||_t |t st j|}| tj}||_ ||_ | ||_ ||_ | |_| pi|_| |_t#|D]} |j dd|_d|_| |_|jr;|jdg|j|jd<|j|jd<dSdS)Nrsocket_optionsproxy proxy_config)r/r9r strict isinstancer( from_floatr'DEFAULTrretriesrQpoolblockrW proxy_headersrXxrangeputnum_connections num_requestsconn_kw setdefault)r7r3r6rYrmaxsizer_headersr]_proxy_proxy_headers _proxy_configre_s r8r9zHTTPConnectionPool.__init__sA dD111g... '7++ 2(11G ?mG  MM'**   +1r)  A IMM$     ! : = L # #$4b 9 9 9$(JDL !+/+Pool reached maximum size and no more connections are allowed.z Resetting dropped connection: %s auto_openrr)r^getr_AttributeErrorrrEmptyrr"rorpr3rFgetattrru)r7rrts r8 _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$rYn4tj$r#t d|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. Fr_Nz2Connection pool is full, discarding connection: %s) r^rbryrFullrowarningr3rFrss r8 _put_connzHTTPConnectionPool._put_conns Y IMM$eM , , , F    Dz Y Y Y KKLdi X X X X X Y   JJLLLLL  s A.AAcdS)U Called right before a request is made, after the socket is created. NrCrss r8_validate_connz!HTTPConnectionPool._validate_conn6rMr:cdSrBrCrss r8_prepare_proxyz!HTTPConnectionPool._prepare_proxy<s r:c|tur|jSt|tr|St j|S)z:Helper that always returns a :class:`urllib3.util.Timeout`)_DefaultrclonerZr(r[)r7rs r8 _get_timeoutzHTTPConnectionPool._get_timeout@sT 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)rZ SocketTimeoutrhasattrr_blocking_errnosstr)r7errurl timeout_values r8_raise_timeoutz!HTTPConnectionPool._raise_timeoutLs c= ) ) "c>N  3  SY2B%B%B"c>N  #c(( " "&?3 D D ' ' #c>N ' ' r:c |xjdz c_||}||j|_ ||n7#t tf$r#}||||jd}~wwxYw |r|j ||fi|n|j ||fi|nM#t$rYnAt$r5}|j tjtjtjhvrYd}~nd}~wwxYw|j} t%|ddrn| dkrt'||d| z| t(jur,|jt1jn|j|  |d} nR#t6$rE |} n,#t8$r}t;j|dYd}~nd}~wwxYwYnwxYwn8#t tt>f$r}|||| d}~wwxYwt%|d d } t@!d |j"|j#|j$||| | j%| j&  tO| j(nO#tRt6f$r;} t@*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),rdr start_connectrrrrrrrrequest_chunkedrequestr IOErrorrEPIPE ESHUTDOWN EPROTOTYPE read_timeoutr{rr(DEFAULT_TIMEOUTr settimeoutsocketgetdefaulttimeout getresponse TypeError BaseExceptionr raise_from SocketErrorrorpr2r3r6statuslengthr&msgrr _absolute_url) r7rtmethodrrchunkedhttplib_request_kw timeout_objerhttplib_response http_versionhpes r8 _make_requestz HTTPConnectionPool._make_requestes" Q''00 !!###"2      % % % %|,      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''           sAB.B  B!B77 D D +C<<D F#"G6# G2.GG2 G, G'"G2'G,,G2/G61G22G66H+ H&&H+;JK!1KKcPt|j|j|j|jS)N)r2r3r6path)r)r2r3r6r)r7rs r8rz HTTPConnectionPool._absolute_urls"$+DIDIDQQQUUr:c|jdS|jdc}|_ |d}|r|-#tj$rYdSwxYw)rLNTFr~)r^rxrFrrz)r7old_poolrts r8rFzHTTPConnectionPool.closes~ 9  F"i$)  !||%|00!JJLLL ! {    DD s.AAAc0|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. /TNr1) startswithr,r+r6rrxr2r3)r7rr2r3r6s r8 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}t|tHtLfrtK|}n`t|tDtNfr|jrtQd |}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|j3dkrd} |)||||}n.#th$r!|j5r|6|cYSwxYw|6|7|t^8d|||j1||||f||||| | | | d| Sts|:d}|;||j3|r |)||||}n.#th$r!|j<r|6|cYSwxYw|6|,|t^8d||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)rbodyrhrrequest_method)r^ connectionr]zCannot 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-r2rhrZr'from_intr]rxrrrr ensure_strr*rr#rWrXcopyupdater`r%rr|rrrr{rr ResponseCls from_httplibrrr rrrrrrr incrementsysrsleeprFrrorurlopenget_redirect_locationrrraise_on_redirect drain_connsleep_for_retryrpbool getheaderis_retryraise_on_status)r7rrrrhr]rrrrrrr response_kw parsed_urldestination_schemertrelease_this_connhttp_tunnel_requiredr clean_exitris_new_proxy_connr response_connrrredirect_locationhas_retry_afters r8rzHTTPConnectionPool.urlopensZs^^ '. ?lG'5)) WnWxVVVG  &??+>#   1.!4!455CC.00C)> J)+=  $ /llnnG NN4- . . . %T844[ %++G44K>>,>77D&6DL $ $ 6!wfd@@< ! *%9 *##D))) $11# 2   )5>DD$M-3K( )5t'4 (   HJJ   J %             J!l,<=>> <QKKA -?@AA O(G MMOOOCCCCCC3 8 ) , $(!  %t$$$ ) , $(!  %t$$$$  %   KKCWcSV    4<  ))! "%I)G)G)I)I  #%% !++FC(RV+WW    ,'')))     ! ! !  # #H - - - II,c3D E E E4<!   !!1))! "x11-@@AA   FHO_ E E  !++FC(RV+WW    *'')))     ! ! ! MM( # # # IIk3 ' ' '4<   !!1))!  sVB+G20M2=L/CL M LM4M7O33(PP?S(TTrB)r>rNrOrPr2r rqr!rr(rr9rur|rrrrrrrrrFrrrCr:r8rSrShsd99vF"MK '4=4=4=4=l*%(%(%(%(N8       / / /4*25u u u u nVVV$KKK2XXXXXXr:rScreZdZdZdZeZddejdddddddddddddddfdZ 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. httpsNFrc tj|||||||||| | f i|| |_| |_| |_||_||_||_||_||_ ||_ dSrB) rSr9key_file cert_file cert_reqs key_passwordca_certs ca_cert_dir ssl_versionassert_hostnameassert_fingerprint)r7r3r6rYrrgr_rhr]rirjrrrrrrrrrres r8r9zHTTPSConnectionPool.__init__rs0 #             ! ""(  &&."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) rZrset_certrrrrrrrrrrss r8 _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_tunnelr5r6r`rWr2tls_in_tls_requiredconnectrss r8rz"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)r3r6rrYrrrrC)rcrorpr3r6rqr rrWrrrrYrrrrer)r7 actual_host actual_portrts r8ruzHTTPSConnectionPool._new_conns ! 7  I I     ! T%7?%J%JU i i : !*/K*/K!t!  L0;n]*   l   !!$'''r:ctt||t|dds||js$t jd|jztdSdS)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-warnings) superrrr{r is_verifiedwarningswarnr3r)r7rt __class__s r8rz"HTTPSConnectionPool._validate_conns !4((77===tVT**  LLNNN  M$'+i0 '       r:)r>rNrOrPr2r rqr(rr9rrrur __classcell__)r s@r8rras  F#M ')/5/5/5/5b(   "("("(Hr:rc t|\}}}|ptj|d}|dkrt|fd|i|St |fd|i|S)a 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', '/') Prr6)r,rrxrrS)rkwr2r3r6s r8connection_from_urlrsn("#FD$  1>%fb11D "499d9b999!$88T8R888r:ct||}|dr|dr |dd}|S)z? Normalize hosts for comparisons and use with sockets. []r)normalize_hostrendswith)r3r2s r8r+r+sN $ ' 'D s c 2 2AbDz Kr:)O __future__rrloggingrrrrrrrrrr r r r r rr exceptionsrrrrrrrrrrrrrpackagesrpackages.six.movesrpackages.ssl_match_hostnamerrr rr!util.connectionr" util.proxyr# util.queuer$ util.requestr% util.responser& util.retryr' util.timeoutr(util.urlr)r*r+rr,r-movesra getLoggerr>roobjectrr/EAGAIN EWOULDBLOCKrrSrrrCr:r8r)ss&&&&&&  ''''''++++++                    %%%%%%999999######""""""222222777777!!!!!!++++++000000!!!!!!))))))))777777))))))))  g!! 688% % % % % V% % % RL%"34v v v v v v v v r\\\\\,\\\~9998r: