Files
intellecton/venv/lib/python3.12/site-packages/requests/__pycache__/adapters.cpython-312.pyc
T

291 lines
29 KiB
Plaintext
Raw Normal View History

Ë
j mãó2dZddlmZddlZddlZddlZddlZddlmZddl m
Z
m Z m Z m
Z
mZmZmZmZddl mZddl mZddl mZdd l mZdd
lmZmZdd lmZdd lm Z dd
l!m"Z"ddl#m$Z$ddl%m&Z&m'Z'ddl(m)Z)ddl*m+Z+m,Z,mZm-Z-m.Z.m/Z/mZm0Z0m1Z1mZddl2m3Z3ddl4m5Z5ddl6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z< ddl=m>Z>ej€rddlAmBZBddlmZCddlDmEZFddl2mGZGddlEmHZIdZJdZKdZLdZM d%dZNGd „d!«ZOGd"„d#eO«ZPy#e?$rd$dZ>YŒawxYw)&z‰
requests.adapters
~~~~~~~~~~~~~~~~~
This module contains the transport adapters that Requests uses to define
and maintain connections.
é)Ú annotationsN)ÚAny)ÚClosedPoolErrorÚConnectTimeoutErrorÚLocationValueErrorÚ
MaxRetryErrorÚNewConnectionErrorÚ
ProtocolErrorÚReadTimeoutErrorÚ
ResponseError)Ú HTTPError)Ú
InvalidHeader)Ú
ProxyError)ÚSSLError)Ú PoolManagerÚproxy_from_url)ÚTimeout)Ú parse_url)ÚRetryé)Ú_basic_auth_str)Ú
basestringÚurlparse)Úextract_cookies_to_jar)
ÚConnectionErrorÚConnectTimeoutrÚInvalidProxyURLÚ
InvalidSchemaÚ
InvalidURLrÚ ReadTimeoutÚ
RetryErrorr)ÚResponse)ÚCaseInsensitiveDict)ÚDEFAULT_CA_BUNDLE_PATHÚget_auth_from_urlÚget_encoding_from_headersÚprepend_scheme_if_neededÚ select_proxyÚ
urldefragauth)ÚSOCKSProxyManagercótd«)Nz'Missing dependencies for SOCKS support.)r)ÚargsÚkwargss úT/home/antigravity/intellecton/venv/lib/python3.12/site-packages/requests/adapters.pyr*r*BsÜÐ)ÚHTTPConnectionPool)r)Ú_types)ÚPreparedRequest)Ú is_preparedFé
có¤i}i}t|j«}|jj«}|j}d} |durd} n:t |t «r*tjj|«s||d<n||d<| |d<|4t |t«rt|«dk(r|d|d <|d
|d <n||d <||j|d œ}||fS)
CERT_REQUIREDFÚ CERT_NONEÚca_certsÚ ca_cert_dirÚ cert_reqsérÚ cert_filerÚkey_file)ÚschemeÚhostÚport)
rÚurlr>Úlowerr@Ú
isinstanceÚstrÚosÚpathÚisdirÚtupleÚlenÚhostname)
ÚrequestÚverifyÚ client_certÚ poolmanagerÚ host_paramsÚ pool_kwargsÚparsed_request_urlr>r@r:s
r.Ú_urllib3_request_contextrRUð #%€KØ"$€KÜ! '§+¡+ÓØ
×
&×
.€FØ × "€Dà€IØ
؉ Ü FœCÔ Üw‰w}‰}˜$Ø&,ˆK˜
Ò #à)/ˆK˜
Ñ (€K ÑØÐÜ k¤5Ô )¬c°+Ó.>À!Ò.CØ'2°1¡~ˆK˜ Ñ $Ø&1°!¡nˆK˜
Ò (3ˆK˜ Ñ Ø"×ñ€Kð
˜ Ð #r/cóZeZdZdZdˆfd Z d ddZddZˆxZS)Ú BaseAdapterzThe Base Transport Adaptercó"t|«y©N)ÚsuperÚ__init__)ÚselfÚ __class__s €r.rXzBaseAdapter.__init__}sø€Ü
ÑÕr/cót)aCSends PreparedRequest object. Returns Response object.
:param request: The :class:`PreparedRequest <PreparedRequest>` being sent.
:param stream: (optional) Whether to stream the request content.
:param timeout: (optional) How long to wait for the server to send
data before giving up, as a float, or a :ref:`(connect timeout,
read timeout) <timeouts>` tuple.
:type timeout: float or tuple
:param verify: (optional) Either a boolean, in which case it controls whether we verify
the server's TLS certificate, or a string, in which case it must be a path
to a CA bundle to use
:param cert: (optional) Any user-provided SSL certificate to be trusted.
:param proxies: (optional) The proxies dictionary to apply to the request.
©ÚNotImplementedError)rYrKÚstreamÚtimeoutrLÚcertÚproxiess r.ÚsendzBaseAdapter.send€s
ô.!r/cót)z!Cleans up adapter specific items.r\)rYs r.ÚclosezBaseAdapter.close™sä!r/©ÚreturnÚNone©FNTNN©rKr2r^Úboolr_z_t.TimeoutTyperLú
_t.VerifyTyper`ú _t.CertTyperaúdict[str, str] | Nonerfr")Ú__name__Ú
__module__Ú __qualname__Ú__doc__rXrbrdÚ
__classcell__©rZs@r.rTrTzsjø„Ùð Ø"&Ø $Ø Ø)-ð ðð ð 
ð  ð

ó"÷2"r/rTcóžeZdZUdZgd¢Zded<ded<ded<ded <d
ed <d
ed <d
ed<ded<eeeef d ˆfd
Z d!dZ
d"dZ ef d#dZ d$dZ
d%dZd&dZ d' d(dZ d) d*dZ d' d+dZd,dZ d-dZd.dZd/dZ d0 d1dZˆxZS)2Ú HTTPAdapteraThe built-in HTTP Adapter for urllib3.
Provides a general-case interface for Requests sessions to contact HTTP and
HTTPS urls by implementing the Transport Adapter interface. This class will
usually be created by the :class:`Session <Session>` class under the
covers.
:param pool_connections: The number of urllib3 connection pools to cache.
:param pool_maxsize: The maximum number of connections to save in the pool.
:param max_retries: The maximum number of retries each connection
should attempt. Note, this applies only to failed DNS lookups, socket
connections and connection timeouts, never to requests where data has
made it to the server. By default, Requests does not retry failed
connections. If you need granular control over the conditions under
which we retry a request, import urllib3's ``Retry`` class and pass
that instead.
:param pool_block: Whether the connection pool should block for connections.
Usage::
>>> import requests
>>> s = requests.Session()
>>> a = requests.adapters.HTTPAdapter(max_retries=3)
>>> s.mount('http://', a)
)Ú max_retriesÚconfigÚ_pool_connectionsÚ
_pool_maxsizeÚ _pool_blockz list[str]Ú __attrs__rrvúdict[str, Any]rwÚ
proxy_managerÚintrxryrjrzÚ _PoolManagerrNcóü|tk(rtdd¬«|_ntj|«|_i|_i|_t |«||_||_ ||_
|j|||¬«y)NrF)Úread©Úblock) ÚDEFAULT_RETRIESrrvÚfrom_intrwr}rWrXrxryrzÚinit_poolmanager)rYÚpool_connectionsÚ pool_maxsizervÚ
pool_blockrZs €r.rXzHTTPAdapter.__init__Ésuø€ð œ/Ò $ Q¨UÔ3ˆDÕ ä$Ÿ~™~¨kÓ:ˆDÔ ØˆŒ ؈Ôä
ÑÔà!1ˆÔØÔØÔà ×ÑÐ ÀJÐÕOr/c óX|jDcic]}|t||d«Œc}Scc}wrV)r{Úgetattr)rYÚattrs r.Ú __getstate__zHTTPAdapter.__getstate__ßs(Ø<@¿N¹NÖK°D”g˜d D¨$ÓKùÒKs'cóÎi|_i|_|j«D]\}}t|||«Œ|j |j
|j |j¬«y)Nr)r}rwÚitemsÚsetattrr†rxryrz)rYÚstaterŒÚvalues r.Ú __setstate__zHTTPAdapter.__setstate__âsfð ˆÔ؈Œ à Ÿ;™;›=ò '‰KˆD D˜$ Õ 
×ÑØ × " D×$6Ñ$6¸d×>NÑ>Nð õ
r/c óV||_||_||_td|||dœ|¤Ž|_y)aInitializes a urllib3 PoolManager.
This method should not be called from user code, and is only
exposed for use when subclassing the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
:param connections: The number of urllib3 connection pools to cache.
:param maxsize: The maximum number of connections to save in the pool.
:param block: Block when no free connections are available.
:param pool_kwargs: Extra keyword arguments used to initialize the Pool Manager.
)Ú num_poolsÚmaxsizerƒ)rxryrzrrN)rYÚ connectionsrrPs r.r†zHTTPAdapter.init_poolmanagerïsAð&"-ˆÔØ$ˆÔØ ˆÔä
ØØñ
ðñ 
ˆÕr/c ó¾||jvr|j|}|S|j«jd«rOt|«\}}t |f|||j
|j |jdœ|¤Žx}|j|<|S|j|«}t|f||j
|j |jdœ|¤Žx}|j|<|S)Return urllib3 ProxyManager for the given proxy.
This method should not be called from user code, and is only
exposed for use when subclassing the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
:param proxy: The proxy to return a urllib3 ProxyManager for.
:param proxy_kwargs: Extra keyword arguments used to configure the Proxy Manager.
:returns: ProxyManager
:rtype: urllib3.ProxyManager
Úsocks)ÚusernameÚpasswordr•r)Ú
proxy_headersr•r)
r}rBÚ
startswithr%r*rxryrzrr)rYÚproxyÚ proxy_kwargsÚmanagerrrs r.Úproxy_manager_forzHTTPAdapter.proxy_manager_for
s ð D× ×Ñ/ˆGð.ˆð-[‰[
% 
.Ü!2°5Ó!9Ñ ˆHhÜ2CØð3à×××
3ðñ3ð
ˆGÑ/ð(ˆð.¨uÓ5ˆMÜ2@Øð3à××× 3ð ñ
3ð
ˆGшr/cóü|j«jd«rw|rud}|dur|}|st}|rtjj |«st
d|«d|_tjj|«s||_ n||_
nd|_d|_ d|_
|rÏt|t«s|d|_
|d|_n||_
d|_|jrAtjj |j«st
d |j«|jrBtjj |j«st
d
|j«yyy) aAVerify a SSL certificate. This method should not be called from user
code, and is only exposed for use when subclassing the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
:param conn: The urllib3 connection object associated with the cert.
:param url: The requested URL.
:param verify: Either a boolean, in which case it controls whether we verify
the server's TLS certificate, or a string, in which case it must be a path
to a CA bundle to use
:param cert: The SSL certificate to verify.
ÚhttpsNTzCCould not find a suitable TLS CA certificate bundle, invalid path: r6r7rrz7Could not find the TLS certificate file, invalid path: z/Could not find the TLS key file, invalid path: )rBr$rErFÚexistsÚOSErrorr:rGr8r9rCrr<r=)rYÚconnrArLr`Úcert_locs r.Ú cert_verifyzHTTPAdapter.cert_verify3sRð 9‰9;× !  *©v؈˜!áÜ1á¤2§7¡7§>¡>°(Ô#;Üð%Ø%- ðð
-ˆDŒNä—7‘7—=‘= Ô*Ø (
à#+Õ à(ˆDŒNØ ˆDŒMØ#ˆDÔ á ܘd¤JÔ/Ø!% a¡Ø $ 
à!%Ø $
Ø~Š~¤b§g¡g§n¡n°T·^±^Ô&DÜð%Ø%)§^¡^Ð$4ððð}Š}¤R§W¡W§^¡^°D·M±MÔ%BÜØEÀdÇmÁmÀ_Ððð&Cˆ r/cóèt|«sJt«}t|dd«|_t t|di««|_t
|j
«|_||_|jj|_ t|jt«r!|jjd«|_ n|j|_ t|j||«||_||_|S)Builds a :class:`Response <requests.Response>` object from a urllib3
response. This should not be called from user code, and is only exposed
for use when subclassing the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>`
:param req: The :class:`PreparedRequest <PreparedRequest>` used to generate the response.
:param resp: The urllib3 response object.
:rtype: requests.Response
ÚstatusNÚheaderszutf-8)Ú _is_preparedr"rÚ status_coder#r&ÚencodingÚrawÚreasonrCrAÚbytesÚdecoderÚcookiesrKÚ
connection)rYÚreqÚrespÚresponses r.Úbuild_responsezHTTPAdapter.build_responsemô˜CÔ Ð Ð Ü“:ˆô ' t¨X°tÓ<ˆÔô/¬w°t¸YÈÓ/KÓÔô6°h×6FÑ6FÓÔØˆŒ Ø"Ÿ,™,׌ä c—g‘gœuÔ Ÿ7™7Ÿ>™>¨'Ó2ˆHŸ7™7ˆHŒLô ˜x×°dÔˆÔØÔàˆr/có2t||||j«S)Build the PoolKey attributes used by urllib3 to return a connection.
This looks at the PreparedRequest, the user-specified verify value,
and the value of the cert parameter to determine what PoolKey values
to use to select a connection from a given urllib3 Connection Pool.
The SSL related pool key arguments are not consistently set. As of
this writing, use the following to determine what keys may be in that
dictionary:
* If ``verify`` is ``True``, ``"ssl_context"`` will be set and will be the
default Requests SSL Context
* If ``verify`` is ``False``, ``"ssl_context"`` will not be set but
``"cert_reqs"`` will be set
* If ``verify`` is a string, (i.e., it is a user-specified trust bundle)
``"ca_certs"`` will be set if the string is not a directory recognized
by :py:func:`os.path.isdir`, otherwise ``"ca_cert_dir"`` will be
set.
* If ``"cert"`` is specified, ``"cert_file"`` will always be set. If
``"cert"`` is a tuple with a second item, ``"key_file"`` will also
be present
To override these settings, one may subclass this class, call this
method and use the above logic to change parameters as desired. For
example, if one wishes to use a custom :py:class:`ssl.SSLContext` one
must both set ``"ssl_context"`` and based on what else they require,
alter the other keys to ensure the desired behaviour.
:param request:
The PreparedRequest being sent over the connection.
:type request:
:class:`~requests.models.PreparedRequest`
:param verify:
Either a boolean, in which case it controls whether
we verify the server's TLS certificate, or a string, in which case it
must be a path to a CA bundle to use.
:param cert:
(optional) Any user-provided SSL certificate for client
authentication (a.k.a., mTLS). This may be a string (i.e., just
the path to a file which holds both certificate and key) or a
tuple of length 2 with the certificate file path and key file
path.
:returns:
A tuple of two dictionaries. The first is the "host parameters"
portion of the Pool Key including scheme, hostname, and port. The
second is a dictionary of SSLContext related parameters.
)rRrN)rYrKrLr`s r.Ú$build_connection_pool_key_attributesz0HTTPAdapter.build_connection_pool_key_attributes“sôd°¸¸t×?OÑ?OÓPr/có¨t|«sJt|j|«} |j|||«\}}|rWt
|d«}t|«} | js td«|j|«}
|
jdi|¤d|i¤Ž} | S|jjdi|¤d|i¤Ž} | S#t$r}t ||¬«d}~wwxYw)auReturns a urllib3 connection for the given request and TLS settings.
This should not be called from user code, and is only exposed for use
when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
:param request:
The :class:`PreparedRequest <PreparedRequest>` object to be sent
over the connection.
:param verify:
Either a boolean, in which case it controls whether we verify the
server's TLS certificate, or a string, in which case it must be a
path to a CA bundle to use.
:param proxies:
(optional) The proxies dictionary to apply to the request.
:param cert:
(optional) Any user-provided SSL certificate to be used for client
authentication (a.k.a., mTLS).
:rtype:
urllib3.HTTPConnectionPool
©rKhttpúFPlease check proxy URL. It is malformed and could be missing the host.rPr—)
r­r(rAÚ
ValueErrorrr'rr?rÚconnection_from_hostrN) rYrKrLrar`rOrPÚeÚ proxy_urlr}s r.Úget_connection_with_tls_contextz+HTTPAdapter.get_connection_with_tls_contextÇsô4˜˜WŸ[™[¨'Ó2ˆð 1Ø'+×'PÑ'PØØØó(Ñ $ˆK˜ñ Ü,¨U°FÓ;ˆ! (ˆ—>ðð2°5Ó9ˆMØ5ØñØ+6òˆDðˆ ð 9ØñØ+6òˆDðˆ øô)ò˜Q¨Ô 0ûð 1ús¥B6Â6 CÂ?
C Ã Ccóftjdt«t||«}|rRt |d«}t |«}|j s td«|j|«}|j|«}|St|«}|j«}|jj|«}|S)aDEPRECATED: Users should move to `get_connection_with_tls_context`
for all subclasses of HTTPAdapter using Requests>=2.32.2.
Returns a urllib3 connection for the given URL. This should not be
called from user code, and is only exposed for use when subclassing the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
:param url: The URL to connect to.
:param proxies: (optional) A Requests-style dictionary of proxies used on this request.
:rtype: urllib3.HTTPConnectionPool
zã`get_connection` has been deprecated in favor of `get_connection_with_tls_context`. Custom HTTPAdapter subclasses will need to migrate for Requests>=2.32.2. Please see https://github.com/psf/requests/pull/6710 for more details.r¾r¿)
ÚwarningsÚwarnÚDeprecationWarningr(r'rr?rÚconnection_from_urlrÚgeturlrN)rYrArar}Úparseds r.Úget_connectionzHTTPAdapter.get_connectionô 
ðNô
ô
ô˜S *ˆá Ü,¨U°FÓ;ˆ! (ˆ—>ðð2°5Ó9ˆMØ ×4°SÓ9ˆDðˆ ô ˜c“]ˆFØ—-‘-“/ˆCØ×7¸Ó<ˆˆ r/có–|jj«|jj«D]}|j«Œy)z¢Disposes of any internal state.
Currently, this closes the PoolManager and any active ProxyManager,
which closes any pooled connections.
N)rNÚclearr}Úvalues)rYs r.rdzHTTPAdapter.close+s=ð
×Ñ×ÑÔ Ø×'× ˆ K‰K r/cóVt|«sJt|j|«}t|j«j}|xr|dk7}d}|r4t|«jj «}|j
d«}|j}|r|st|j«}|S)a?Obtain the url to use when making the final request.
If the message is being sent through a HTTP proxy, the full URL has to
be used. Otherwise, we should only use the path portion of the URL.
This should not be called from user code, and is only exposed for use
when subclassing the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
:param request: The :class:`PreparedRequest <PreparedRequest>` being sent.
:param proxies: A dictionary of schemes or schemes and hosts to proxy URLs.
:rtype: str
Frš) r­r(rArr>rBÚpath_urlr)) rYrKrar>Úis_proxied_http_requestÚusing_socks_proxyÚ proxy_schemerAs r.Ú request_urlzHTTPAdapter.request_url5ô ˜˜WŸ[™[¨'Ó2ˆÜ˜'Ÿ+™+Ó&×-ˆà"'Ò"=¨F°gÑ,=ÐØÙ Ü# E›?×9ˆLØ ,× 7Ñ 7¸Ó @Ð à×шá "Ñ+<Ü § ¡ Ó,ˆˆ
r/c óy)a"Add any headers needed by the connection. As of v2.0 this does
nothing by default, but is left for overriding by users that subclass
the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
This should not be called from user code, and is only exposed for use
when subclassing the
:class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
:param request: The :class:`PreparedRequest <PreparedRequest>` to add headers to.
:param kwargs: The keyword arguments from the call to send().
Nr—)rYrKr-s r.Ú add_headerszHTTPAdapter.add_headersWsð
r/cóHi}t|«\}}|rt||«|d<|S)aReturns a dictionary of the headers to add to any request sent
through a proxy. This works with urllib3 magic to ensure that they are
correctly sent to the proxy, rather than in a tunnelled request if
CONNECT is being used.