Move _get_connection to get_connection_with_tls_context
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Nate Prewitt · committed by Nate Prewitt · parent 970e8ce · Browse files · 1 file·+21 added−6 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+21 added−6 removed
- other:+21 added−6 removed
Provenance
- Commit
aa1461b- Tree
fcf8b82- Author
Nate Prewitt <nate.prewitt@gmail.com>- Committer
Nate Prewitt <nate.prewitt@gmail.com>- Parent
970e8ce
1 file changed+21 added−6 removed
modified:src/requests/adapters.py+21 added-6 removed
372 unmodified lines373 response.connection = self374 375 return response376 377- def _get_connection(self, request, verify, proxies=None, cert=None):378- # Replace the existing get_connection without breaking things and379- # ensure that TLS settings are considered when we interact with380- # urllib3 HTTP Pools377+ 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 use380+ when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.381+382+ :param request: The :class:`PreparedRequest <PreparedRequest>` object383+ to be sent over the connection.384+ :param verify: Either a boolean, in which case it controls whether385+ we verify the server's TLS certificate, or a string, in which case it386+ 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.ConnectionPool390+ """391 proxy = select_proxy(request.url, proxies)392 try:393 host_params, pool_kwargs = _urllib3_request_context(request, verify, cert)394 except ValueError as e:18 unmodified lines413 414 return conn415 416 def get_connection(self, url, proxies=None):417+ """DEPRECATED: Users should move to `get_connection_with_tls_context`418+ for all subclasses of HTTPAdapter using Requests>=2.32.2.419+407- """Returns a urllib3 connection for the given URL. This should not be420+ Returns a urllib3 connection for the given URL. This should not be421 called from user code, and is only exposed for use when subclassing the422 :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.423 424 :param url: The URL to connect to.116 unmodified lines541 :rtype: requests.Response542 """543 544 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=cert547+ )548 except LocationValueError as e:549 raise InvalidURL(e, request=request)550 551 self.cert_verify(conn, request.url, verify, cert)80 unmodified lines