@@ -374,10 +374,20 @@ def build_response(self, req, resp):
374374
375375 return response
376376
377- def _get_connection (self , request , verify , proxies = None , cert = None ):
378- # Replace the existing get_connection without breaking things and
379- # ensure that TLS settings are considered when we interact with
380- # urllib3 HTTP Pools
377+ def get_connection_with_tls_context (self , request , verify , proxies = None , cert = None ):
378+ """Returns a urllib3 connection for the given request and TLS settings.
379+ This should not be called from user code, and is only exposed for use
380+ when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
381+
382+ :param request: The :class:`PreparedRequest <PreparedRequest>` object
383+ to be sent over the connection.
384+ :param verify: Either a boolean, in which case it controls whether
385+ we verify the server's TLS certificate, or a string, in which case it
386+ must be a path to a CA bundle to use.
387+ :param proxies: (optional) The proxies dictionary to apply to the request.
388+ :param cert: (optional) Any user-provided SSL certificate to be trusted.
389+ :rtype: urllib3.ConnectionPool
390+ """
381391 proxy = select_proxy (request .url , proxies )
382392 try :
383393 host_params , pool_kwargs = _urllib3_request_context (request , verify , cert )
@@ -404,7 +414,10 @@ def _get_connection(self, request, verify, proxies=None, cert=None):
404414 return conn
405415
406416 def get_connection (self , url , proxies = None ):
407- """Returns a urllib3 connection for the given URL. This should not be
417+ """DEPRECATED: Users should move to `get_connection_with_tls_context`
418+ for all subclasses of HTTPAdapter using Requests>=2.32.2.
419+
420+ Returns a urllib3 connection for the given URL. This should not be
408421 called from user code, and is only exposed for use when subclassing the
409422 :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
410423
@@ -529,7 +542,9 @@ def send(
529542 """
530543
531544 try :
532- conn = self ._get_connection (request , verify , proxies = proxies , cert = cert )
545+ conn = self .get_connection_with_tls_context (
546+ request , verify , proxies = proxies , cert = cert
547+ )
533548 except LocationValueError as e :
534549 raise InvalidURL (e , request = request )
535550
0 commit comments