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

267 lines
28 KiB
Plaintext
Raw Normal View History

2025-06-23 17:55:02 -05:00
Ë
Œ»Yh;kãóh—dZddlZddlZddlZddlZddlmZmZddlm Z
ddlm Z ddlm
Z
mZmZmZddlmZddlmZmZdd lmZdd
lmZmZdd lmZdd lmZdd
lmZddl m!Z!ddl"m#Z#ddl$m%Z%m&Z&ddl'm(Z(ddl)m*Z*m+Z+m Z m,Z,m-Z-m.Z.mZm/Z/m0Z0mZddl1m2Z2ddl3m4Z4ddl5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z< ddl=m>Z>ej€rddl1mAZAdZBdZCdZDdZE ddlFZFe!«ZGeGj‘e7e6«« d!d„ZIGd„d«ZJGd„d eJ«ZKy#e?$rd„Z>YŒkwxYw#e?$rdZGYŒ;wxYw)"z‰
requests.adapters
~~~~~~~~~~~~~~~~~
This module contains the transport adapters that Requests uses to define
and maintain connections.
éN)ÚClosedPoolErrorÚConnectTimeoutError)Ú HTTPError)Ú
InvalidHeader)ÚLocationValueErrorÚ
MaxRetryErrorÚNewConnectionErrorÚ
ProtocolError)Ú
ProxyError)ÚReadTimeoutErrorÚ
ResponseError)ÚSSLError)Ú PoolManagerÚproxy_from_url)ÚTimeout)Ú parse_url)ÚRetry)Úcreate_urllib3_contexté)Ú_basic_auth_str)Ú
basestringÚurlparse)Úextract_cookies_to_jar)
ÚConnectionErrorÚConnectTimeoutrÚInvalidProxyURLÚ
InvalidSchemaÚ
InvalidURLr Ú ReadTimeoutÚ
RetryErrorr)ÚResponse)ÚCaseInsensitiveDict)ÚDEFAULT_CA_BUNDLE_PATHÚextract_zipped_pathsÚ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 úZ/mnt/c/fieldcraft/witness-fracture/.venv/lib/python3.12/site-packages/requests/adapters.pyr*r*?s€ÜÐEÓFÐFó)ÚPreparedRequestFé
có—i}i}t|j«}|jj«}|j}t |di«} | j
d«}
tduxr|
} d} |durd} nJ|dur | r
t|d<n:t|t«r*tjj|«s||d<n||d<| |d <|�4t|t«rt|«d
k(r|d |d <|d
|d<n||d <||j|dœ}||fS)NÚconnection_pool_kwÚ ssl_contextÚ
CERT_REQUIREDFÚ CERT_NONETÚca_certsÚ ca_cert_dirÚ cert_reqsérÚ cert_filerÚkey_file)ÚschemeÚhostÚport)rÚurlr=Úlowerr?ÚgetattrÚgetÚ_preloaded_ssl_contextÚ
isinstanceÚstrÚosÚpathÚisdirÚtupleÚlenÚhostname)
ÚrequestÚverifyÚ client_certÚ poolmanagerÚ host_paramsÚ pool_kwargsÚparsed_request_urlr=r?Úpoolmanager_kwargsÚhas_poolmanager_ssl_contextÚshould_use_default_ssl_contextr9s
r.Ú_urllib3_request_contextrWZs;€ð €KØ€KÜ! '§+¡+Ó.ÐØ
×
&Ñ
&×
,Ñ
,Ó
.€FØ × "Ñ "€Dô! Ð.BÀBÓGÐØ"4×"8Ñ"8¸Ó"GÐä dÐ*ÒNÐ3NÐ/Nð#ð €IØ
��؉ Ø �4‰Ñ:Ü%;ˆ �MÒ"Ü �FœCÔ Ü�w‰w�}‰}˜VÔ$Ø&,ˆK˜
Ò #à)/ˆK˜
Ñ &Ø(€K� ÑØÐÜ �k¤5Ô )¬c°+Ó.>À!Ò.CØ'2°1¡~ˆK˜ Ñ $Ø&1°!¡nˆK˜
Ò #ð(3ˆK˜ Ñ $àØ"×+Ñ+Øñ€Kð
˜ Ð #Ð#r/có2‡—eZdZdZˆfd„Z dd„Zd„ZˆxZS)Ú BaseAdapterzThe Base Transport Adaptercó"•—t‰|�«y©N)ÚsuperÚ__init__)ÚselfÚ __class__s €r.r]zBaseAdapter.__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)r^rMÚstreamÚtimeoutrNÚcertÚproxiess r.ÚsendzBaseAdapter.send�s
€ô""Ð!r/có—t‚)z!Cleans up adapter specific items.ra)r^s r.ÚclosezBaseAdapter.close¢s€ä!Ð!r/©FNTNN)Ú__name__Ú
__module__Ú __qualname__Ú__doc__r]rgriÚ
__classcell__©r_s@r.rYrY‰sø„Ù$ôðTXó"ö&"r/rYcó–‡—eZdZdZgd¢Zeeeefˆfd„ Zd„Z d„Z
efd„Z d„Z d„Z
d „Zdd
„Zdd „Zdd „Zd
„Zd„Zd„Zd„Z dd„ZˆxZS)Ú HTTPAdaptera�The 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_blockcóü•—|tk(rtdd¬«|_ntj|«|_i|_i|_t ‰|�«||_||_ ||_
|j|||¬«y)NrF)Úread©Úblock) ÚDEFAULT_RETRIESrrsÚfrom_intrtÚ
proxy_managerr\r]rurvrwÚinit_poolmanager)r^Úpool_connectionsÚ pool_maxsizersÚ
pool_blockr_s €r.r]zHTTPAdapter.__init__Êsuø€ð œ/Ò )Ü$ Q¨UÔ3ˆDÕ ä$Ÿ~™~¨kÓ:ˆDÔ ØˆŒ ؈Ôä
‰ÑÔà!1ˆÔØ)ˆÔØ%ˆÔà ×ÑÐ.° ÀJÐÕOr/c óX—|jD�cic]}|t||d«“Œc}Scc}wr[)Ú __attrs__rB)r^Úattrs r.Ú __getstate__zHTTPAdapter.__getstate__às(€Ø<@¿N¹NÖK°D�”g˜d D¨$Ó/Ñ/ÒKÐKùÒKs�'cóΗi|_i|_|j«D]\}}t|||«Œ|j |j
|j |j¬«y)Nrz)r~rtÚitemsÚsetattrrrurvrw)r^Ú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{N©)rurvrwrrP)r^Ú connectionsr�r{rRs r.rzHTTPAdapter.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)aÏ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�r{)Ú
proxy_headersrŽr�r{)
r~rAÚ
startswithr%r*rurvrwr–r)r^ÚproxyÚ proxy_kwargsÚmanagerr”r•r–s r.Úproxy_manager_forzHTTPAdapter.proxy_manager_for
s €ð �D×&Ñ&Ñ &Ø×(Ñ(¨Ñ/ˆGð.ˆð-�[‰[‹]×
%Ñ
% gÔ
.Ü!2°5Ó!9Ñ ˆH�hÜ2CØð3à!Ø!Ø×0Ñ0Ø×*Ñ*Ø×&Ñ&ñ
3ðñ3ð
ˆG�d×(Ñ(¨Ñ/ð(ˆð!×.Ñ.¨uÓ5ˆMÜ2@Øð3à+Ø×0Ñ0Ø×*Ñ*Ø×&Ñ&ñ 3ð ñ
3ð
ˆG�d×(Ñ(¨Ñ/ðˆr/cóä—|j«jd«rk|rid|_|durs|}tjj |«st
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.
Úhttpsr5TzCCould not find a suitable TLS CA certificate bundle, invalid path: r6Nrrz7Could not find the TLS certificate file, invalid path: z/Could not find the TLS key file, invalid path: )rAr—r9rGrHÚexistsÚOSErrorrIr7r8rErr;r<)r^Úconnr@rNreÚcert_locs r.Ú cert_verifyzHTTPAdapter.cert_verify0sC€ð �9‰9‹;× !Ñ ! 'Ô *©vØ,ˆDŒNð ˜TÑ!à!�ä—w‘w—~‘~ hÔ/Ü!ð)Ø)1¨
ð4óðô
—w‘w—}‘} XÔ.Ø$,�D•Mà'/�DÕ$à(ˆDŒNØ ˆDŒMØ#ˆDÔ á ܘd¤JÔ/Ø!% a¡�”Ø $ Q¡�•
à!%�”Ø $�”
Ø�~Š~¤b§g¡g§n¡n°T·^±^Ô&DÜð%Ø%)§^¡^Ð$4ð6óðð�}Š}¤R§W¡W§^¡^°D·M±MÔ%BÜØEÀdÇmÁmÀ_ÐUóðð&Cˆ}ð r/cóΗt«}t|dd«|_tt|di««|_t |j«|_||_|jj|_t|jt«r!|jjd«|_
n|j|_
t|j||«||_||_|S)a¶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)r!rBÚ status_coder"r¥r&ÚencodingÚrawÚreasonrEr@ÚbytesÚdecoderÚcookiesrMÚ
connection)r^ÚreqÚrespÚresponses r.Úbuild_responsezHTTPAdapter.build_responsegs»€ô“:ˆô ' t¨X°tÓ<ˆÔô/¬w°t¸YÈÓ/KÓLˆÔô6°h×6FÑ6FÓGˆÔ؈Œ Ø"Ÿ,™,×-Ñ-ˆŒä �c—g‘gœuÔ %ØŸ7™7Ÿ>™>¨'Ó2ˆH�LàŸ7™7ˆHŒLô ˜x×/Ñ/°°dÔ;ðˆÔØ"ˆÔàˆr/có2—t||||j«S)a§ 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_certs_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 PreparedReqest 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.
)rWrP)r^rMrNres r.Ú$build_connection_pool_key_attributesz0HTTPAdapter.build_connection_pool_key_attributesŒs€ô`(¨°¸¸t×?OÑ?OÓPÐPr/cóŽ—t|j|«} |j|||«\}}|rWt |d«}t
|«} | js td«‚|j|«}
|
jdi|¤d|i¤Ž} | S|jjdi|¤d|i¤Ž} | S#t$r}t ||¬«‚d}~wwxYw)aqReturns 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.ConnectionPool
©rMNÚhttpúFPlease check proxy URL. It is malformed and could be missing the host.rRr�) r(r@r³Ú
ValueErrorrr'rr>rr›Úconnection_from_hostrP) r^rMrNrfrer˜rQrRÚeÚ proxy_urlr~r s r.Úget_connection_with_tls_contextz+HTTPAdapter.get_connection_with_tls_context¾sö€ô(˜WŸ[™[¨'Ó2ˆð 1Ø'+×'PÑ'PØØØó(Ñ $ˆK˜ñ Ü,¨U°FÓ;ˆEÜ! %Ó(ˆIØ—>’>Ü%ð5óðð!×2Ñ2°5Ó9ˆMØ5�=×5Ñ5ñØñØ+6òˆDðˆ ð 9�4×#Ñ#×8Ñ8ñØñØ+6òˆDðˆ øô)ò 1ܘQ¨Ô0Ð 0ûð 1ús˜B)Â) CÂ2
B?Â?Ccóf—tjdt«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.ConnectionPool
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>rr›Úconnection_from_urlrÚgeturlrP)r^r@rfr˜r»r~r Úparseds r.Úget_connectionzHTTPAdapter.get_connectionïsµ€ô �
‰
ðNô
ô
ô˜S 'Ó*ˆá Ü,¨U°FÓ;ˆEÜ! %Ó(ˆIØ—>’>Ü%ð5óðð!×2Ñ2°5Ó9ˆMØ ×4Ñ4°SÓ9ˆDðˆ ô ˜c“]ˆFØ—-‘-“/ˆCØ×#Ñ#×7Ñ7¸Ó<ˆDàˆ 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)rPÚclearr~Úvalues)r^r˜s r.rizHTTPAdapter.closes=€ð
×Ñ×ÑÔ Ø×'Ñ'×.Ñ.Ó0ò ˆEØ �K‰K�Mñ r/có†—t|j|«}t|j«j}|xr|dk7}d}|r4t|«jj «}|j d«}|j }|j d«rd|jd«›�}|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