bgѧddlmZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z ddlmZddlmZddlmZmZmZmZmZmZmZmZdd lmZdd lmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)dd l*m+Z+dd l,m-Z-dd l.m/Z/ddl0m1Z1m2Z2ddl3m4Z4ddl5m6Z6ddl7m8Z8m9Z9m:Z:ddl;mZ?ddl;m@Z@ddlAmBZBejCrddlDZDddlEmFZFddlmGZGmHZHejIeJZKejLe:eMe9dfZNejOdZPGddZQejRejShZTGddeQeZUGddeUZVd2d$ZWejXd3d)Z>ejXd4d*Z>d5d+Z> d6d7d/ZYd8d1ZZdS)9) annotationsNtimeout) TracebackType) _TYPE_BODY)RequestMethods) BaseSSLErrorBrokenPipeErrorDummyConnectionHTTPConnection HTTPExceptionHTTPSConnection ProxyConfig_wrap_proxy_error)port_by_scheme) ClosedPoolErrorEmptyPoolError FullPoolErrorHostChangedErrorInsecureRequestWarningLocationValueError MaxRetryErrorNewConnectionError ProtocolError ProxyErrorReadTimeoutErrorSSLError TimeoutError)BaseHTTPResponse)is_connection_dropped)connection_requires_http_tunnel)_TYPE_BODY_POSITIONset_file_position)Retry)CertificateError)_DEFAULT_TIMEOUT _TYPE_DEFAULTTimeout)Url_encode_target)_normalize_host) parse_url)to_str)Literal)BaseHTTPConnectionBaseHTTPSConnection_SelfTcZeZdZUdZdZded<ejZddd Z dd Z ddZ ddZ ddZ 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. N str | Noneschemehoststrport int | NonereturnNonec|stdt||j|_||_t ||j|_dS)NzNo host specified.r6)rr,r6r7r9normalize_hostlower _tunnel_host)selfr7r9s M/opt/cloudlinux/venv/lib64/python3.11/site-packages/urllib3/connectionpool.py__init__zConnectionPool.__init__Rsa ;$%9:: :#D===  +4 DDDJJLLcPt|jd|jd|jdS)Nz(host=z, port=))type__name__r7r9rBs rC__str__zConnectionPool.__str___s.t**%OOTYOOOOOOrErBr2c|SNrJs rC __enter__zConnectionPool.__enter__bs rEexc_typetype[BaseException] | Noneexc_valBaseException | Noneexc_tbTracebackType | NoneLiteral[False]c.|dS)NF)close)rBrPrRrTs rC__exit__zConnectionPool.__exit__es urEcdSzD Close all pooled connections and disable the pool. NrNrJs rCrXzConnectionPool.closeorErM)r7r8r9r:r;r<)r;r8)rBr2r;r2)rPrQrRrSrTrUr;rVr;r<)rI __module__ __qualname____doc__r6__annotations__queue LifoQueueQueueClsrDrKrOrYrXrNrErCr4r4DsFH M M M M MPPPP      rEr4c eZdZUdZdZeZded<dedddddddf dHdZ dId Z dJdKd"Z dLd&Z dMd'Z dMd(ZdNd+ZdOd0Zdddeddd1d1d1f dPd<ZdQd=ZdRd>Zdddd1d1eddddd1d1f dSdGZdS)THTTPConnectionPoola 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 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. httpz4type[BaseHTTPConnection] | type[BaseHTTPSConnection] ConnectionClsNrFr7r8r9r:r_TYPE_TIMEOUT | Nonemaxsizeintblockboolheaderstyping.Mapping[str, str] | NoneretriesRetry | bool | int | None_proxy Url | None_proxy_headers _proxy_configProxyConfig | Noneconn_kw typing.Anyc  t|||tj||t|tst j|}| t j}||_||_ | ||_ ||_ ||_ | pi|_| |_t!|D]} |j dd|_d|_| |_|j r9|jdg|j |jd<|j|jd<|j } t-j|t0| dS)Nrsocket_optionsproxy proxy_config)r4rDr isinstancer) from_floatr%DEFAULTrrprdpoolrlr{ proxy_headersr|rangeputnum_connections num_requestsrw setdefaultweakreffinalize_close_pool_connections)rBr7r9rrjrlrnrprrrtrurw_rs rCrDzHTTPConnectionPool.__init__sQ dD111g...'7++ 2(11G ?mG  8< g8N8N   +1r)w  A IMM$     ! : = L # #$4b 9 9 9$(JDL !+/+Pool reached maximum size and no more connections are allowed.zLConnection pool is full, discarding connection: %s. Connection pool size: %s) rrrrbFullrXrlrrwarningr7qsizers rC _put_connzHTTPConnectionPool._put_conn)s 9   d% 000!   :   !JJLLL: 'X   bIIOO%% &   JJLLLLL  s' B*A4B*)B*cdS)U Called right before a request is made, after the socket is created. NrNrs rC_validate_connz!HTTPConnectionPool._validate_connTr\rEcdSrMrNrs rC_prepare_proxyz!HTTPConnectionPool._prepare_proxyYs rE _TYPE_TIMEOUTr)c|tur|jSt|tr|St j|S)z:Helper that always returns a :class:`urllib3.util.Timeout`)r'rcloner}r)r~)rBrs rC _get_timeoutzHTTPConnectionPool._get_timeout]sU & & &<%%'' ' gw ' ' /==?? "%g.. .rEerr&BaseSSLError | OSError | SocketTimeouturl timeout_valuect|trt||d|d|t|dr$|jt vrt||d|d|dSdS)zAIs the error actually a timeout? Will raise a ReadTimeout or passRead timed out. (read timeout=rGerrnoN)r} SocketTimeoutrhasattrr_blocking_errnos)rBrrrs rC_raise_timeoutz!HTTPConnectionPool._raise_timeoutis c= ) ) "cLMLLL  3  SY2B%B%B"cLMLLL   %B%BrETmethodbody_TYPE_BODY | None Retry | Nonechunked response_connpreload_contentdecode_contentenforce_content_lengthr c |xjdz c_||} | tj| j|_ ||n7#ttf$r#}| |||jd}~wwxYwn#ttttttf$r}|}t!|ttfrt|}t!|ttttfr*|r(|jr!|jst'||jj}|d}~wwxYw ||||||| | | n8#t,$rYn,t$r }|jt.jkrYd}~nd}~wwxYw| j}|js"|dkrt7||d|d||_ |}n2#ttf$r}| |||d}~wwxYw||_| |_||_t@!d|j|j"|j#|||j$|j%|j& |S) a8 Perform a request on a given urllib connection object taken from our pool. :param conn: a connection from one of our connection pools :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 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 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 response_conn: Set this to ``None`` if you will handle releasing the connection or set the connection to have the response release it. :param preload_content: If True, the response's body will be preloaded during construction. :param decode_content: If True, will attempt to decode the body based on the 'content-encoding' header. :param enforce_content_length: Enforce content length checking. Body returned by server must match value of Content-Length header, if present. Otherwise, raise error. rrrrN)rrnrrrrrrrGz%s://%s:%s "%s %s %s" %s %s)'rr start_connectr)resolve_default_timeoutrrrrr rOSErrorrrr&rr}r{has_connected_to_proxyrr6requestr r EPROTOTYPE read_timeout is_closedr getresponserp _connection_poolrrr7r9 _http_vsn_strstatuslength_remaining)rBrrrrrnrprrrrrr timeout_objenew_erresponses rC _make_requestz HTTPConnectionPool._make_request|s\ Q''00 !!###6{7RSS   ##D))))!<0   ##s$,#OOO *            !E!l,<=>> $  !3\8L D D J D/3/J D*%1BCCK# *  LL /-'=         D   w%***+****  #/ ~ ( q  &#O OOO(DL ''))HHg&      A3l  K K K   #, ) K I I     O  % smA0/B(0B$BB$$B(()EBEEE99 F. F.F))F."G77H&H!!H&cT|jdS|jdc}|_t|dSr[)rr)rBold_pools rCrXzHTTPConnectionPool.close1s7 9  F"i$) )))))rEc:|drdSt|^}}}}}|pd}|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. /TrgNr>) startswithr-r,r9rrr6r7)rBrr6rr7r9s rC is_same_hostzHTTPConnectionPool.is_same_host=s >>#   4%.cNN!4!6  "4777D 9 T !%f--DD t~'9&'A'AAADd# TY 'JJJrEredirectassert_same_host pool_timeout release_conn bool | Nonebody_pos_TYPE_BODY_POSITION | None response_kwc @ t|}|j}||j}t|tst j|||j}| | } |r&||st|||| drtt|}nt|j }d}| }t|j|j|}|s.|}||jd}d}t'|| } ||}|| }|j|_|jg|re|jr^ ||nG#t4t6t8f$r-}|||jj |jd}~wwxYw| s|nd}|j|||f|||| ||| |d|}d}nL#t>$rd}d}t@tBt6tDt4tFtHtJf$r}d}|}t|t4tHfrtG|}t|t6tLt@tFtBfr+|r)|jr"|j'stQ||jj}n,t|t6tBfrtEd |}|)||||tUj+d  }|,|}Yd}~nd}~wwxYw|s|r|-d}d}|r|.|n9#|s|r|-d}d}|r|.|wwxYw|s9t^0d ||||j1|||||||f|| | | | | |d |S|o|2}|r|j3dkrd} |)||||}n.#th$r!|j5r|6|cYSwxYw|6|7|t^8d|||j1||||f||||| | | | | |d |Sts|j:d}|;||j3|r |)||||}n.#th$r!|j<r|6|cYSwxYw|6|,|t^8d||j1||||f||||| | | | | |d |S|S)ay 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 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 bool preload_content: If True, the response's body will be preloaded into memory. :param bool decode_content: If True, will attempt to decode the body based on the 'content-encoding' header. :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 ``preload_content`` which defaults to ``True``. :param bool 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. N)rdefaultrFrr)rrrnrrprrrTzConnection aborted.)errorr _stacktracez1Retrying (%r) after connection broken by '%r': %s)rrrrrrri/GET)rrzRedirecting %s -> %s) rprrrrrrrrrz Retry-Afterz Retry: %s)=r-r6rnr}r%from_intrprrrr.r+rr"r{r|copyupdaterr$rrrrrrr rrrrrrrrrr&rrrr incrementsysexc_infosleeprXrrrurlopenget_redirect_locationrrraise_on_redirect drain_connsleep_for_retryrrmris_retryraise_on_status)rBrrrrnrprrrrrrrrrr parsed_urldestination_schemerrelease_this_connhttp_tunnel_requiredr clean_exitrrrrrredirect_locationhas_retry_afters rCrzHTTPConnectionPool.urlopenSsYbs^^ '. ?lG'5)) WnWxVVVG  *L  7D$5$5c$:$: 7"4g66 6 >>#   ),,--CC((C)> J)+=  $ /llnnG NN4- . . . %T844e %++G44K>>,>77D&6DLz%*>%4>%''----$g}=''4:>( )5>DD$M*t) $+ /-    H JJ   J %            $ $ $ J E!l,<=>> $  & !    D D!J D04/J D*%1BCCEG]#;<< D%&;UCC''5#,..QRBS(G MMOOOCCCCCCI$ N )  JJLLLD$(!  %t$$$ )  JJLLLD$(!  %t$$$$  %   KKCWcSV    4<  ))! /- &%I)G)G)I)I  #%% !++FC(RV+WW    ,'')))     ! ! !  # #H - - - II,c3D E E E4<!   !!1))! /- &x/33MBBCC   FHO_ E E  !++FC(RV+WW    *'')))     ! ! ! MM( # # # IIk3 ' ' '4<   !!1))! /- $s{'AG//FG/G (GG  $G/-M//AL83C;L3.M/3L88M//6N% P##(Q Q6T(T;:T;)r7r8r9r:rrirjrkrlrmrnrorprqrrrsrtrorurvrwrx)r;r0rM)rrr;r0)rrr;r<rr0r;r<)rrr;r))rrrr8rrir;r<)rr0rr8rr8rrrnrorprrrrrmrrrrmrrmrrmr;r r])rr8r;rm) rr8rr8rrrnrorprqrrmrrmrrrr:rrrrmrrrrmrrmrrxr;r )rIr^r_r`r6r rhrar'rDrrrrrrrrrXrrrNrErCrfrfys11fF  (837-1!:>,0;>;>;>;>;>z($($($($($(L))))V         / / / /0#'37 $!137 $#'+sssssj * * * *KKKK4#'37-1!%!1#'$(/3 $#lllllllrErfc|eZdZUdZdZeZded<dedddddddddddddddddfd4fd, Z d5d/Z d6d1Z d7fd3 Z xZ S)8HTTPSConnectionPoola 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. httpsztype[BaseHTTPSConnection]rhNrFr7r8r9r:rrirjrkrlrmrnrorprqrrrsrtkey_filer5 cert_file cert_reqsint | str | None key_passwordca_certs ssl_versionssl_minimum_versionssl.TLSVersion | Nonessl_maximum_versionassert_hostnamestr | Literal[False] | Noneassert_fingerprint ca_cert_dirrwrxr;r<c tj||||||||| f i|| |_| |_| |_| |_||_||_||_||_ ||_ ||_ ||_ dSrM) superrDrrrrrr rrrr r )rBr7r9rrjrlrnrprrrtrrrrrrrrr r r rw __class__s rCrDzHTTPSConnectionPool.__init__s0            ! ""(  &&#6 #6 ."4rErrc|jr|jjdkrd}nd}|||j|j|j|dS)z5Establishes a tunnel connection through HTTP CONNECT.rrg)r6r7r9rnN)r{r6 set_tunnelrAr9rconnect)rBr tunnel_schemes rCrz"HTTPSConnectionPool._prepare_proxysi : #$*+w66#MM"M  "&    rEr1c|xjdz c_td|j|j|jpd|jr|jt urtd|j}|j}|j$|jj|jj}|jj}|jd|||j j |j |j |j |j|j|j|j|j|j|j|jd|jS)zL Return a fresh :class:`urllib3.connection.HTTPConnection`. rz)Starting new HTTPS connection (%d): %s:%s443zCCan't connect to HTTPS URL because the SSL module is not available.N)r7r9rrrrrrr r r rrrrN)rrrr7r9rhr ImportErrorr{rrrrrrrr r r rrrrw)rB actual_host actual_ports rCrzHTTPSConnectionPool._new_conns! ! 7  I I     ! T%7?%J%JU  9 i : !djo&A*/K*/K!t! L0n]*n]( 0#6( $ 8 $ 8  l   rEr0ct||jr||js%t jd|jdtdSdS)rz0Unverified HTTPS request is being made to host 'z'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warningsN) rrrr is_verifiedwarningswarnr7r)rBrrs rCrz"HTTPSConnectionPool._validate_conn<s t$$$ >  LLNNN  M$ty$$$ '       rE),r7r8r9r:rrirjrkrlrmrnrorprqrrrsrtrorr5rr5rrrr5rr5rrrrrrr r r r5r r5rwrxr;r<)rrr;r<)r;r1r)rIr^r_r`r6rrhrar'rDrrr __classcell__)rs@rCrrs  F/>M>>>>  (837-1!:># $&*#'#(,59597;)-"&+/5/5/5/5/5/5/5b    ' ' ' ' RrErrr8kwrxr;c t|^}}}}}|pd}|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', '/') rgPrr9)r-rrrrf)rrr6rr7r9s rCconnection_from_urlr!Rs|(!*#FAtTA  vF  1>%fb11D "499d9b999!$88T8R888rEr7r<r6r5cdSrMrNr7r6s rCr,r,oCrEcdSrMrNr#s rCr,r,tr$rEct||}|r4|dr|dr |dd}|S)z? Normalize hosts for comparisons and use with sockets. []r)r?rendswithr#s rCr,r,ysU $ ' 'D $$s););AbDz KrEr(HTTPConnectionPool | HTTPSConnectionPoolpathcPt|j|j|j|jS)zZReturns the URL from a given connection pool. This is mainly used for testing and logging.)r6r7r9r,)r*r6r7r9r)rr,s rC_url_from_poolr.s$ dk   M M M QQrEqueue.LifoQueue[typing.Any]c |d}|r|-#tj$rYdSwxYw)z2Drains a queue of connections and closes each one.TFrN)rrXrbr)rrs rCrrs_  88%8((D    ;     s.0AA)rr8rrxr;rf)r7r<r6r5r;r<)r7r8r6r5r;r8)r7r5r6r5r;r5rM)rr+r,r5r;r8)rr/r;r<)[ __future__rrloggingrbrtypingrrsocketrrtypesr_base_connectionr_request_methodsr connectionr r r r rrrrr exceptionsrrrrrrrrrrrrrrr util.connectionr! util.proxyr" util.requestr#r$ util.retryr%util.ssl_match_hostnamer& util.timeoutr'r(r)util.urlr*r+r,r?r- util.utilr. TYPE_CHECKINGssltyping_extensionsr/r0r1 getLoggerrIrUnionfloatrTypeVarr2r4EAGAIN EWOULDBLOCKrrfrr!overloadr.rrNrErCrLsV""""""  ++++++((((((,,,,,,                    988888'&&&&&222222777777@@@@@@@@555555BBBBBBBBBB))))))))777777 JJJJ))))))IIIIIIIIg!! We]D@A  ! !. . . . . . . . dL%"34F F F F F F F F RMMMMM,MMM`9999:&HLRRRRR      rE