MCPcopy
hub / github.com/psf/requests / get_connection_with_tls_context

Method get_connection_with_tls_context

src/requests/adapters.py:455–510  ·  view source on GitHub ↗

Returns 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 <Prep

(
        self,
        request: PreparedRequest,
        verify: _t.VerifyType,
        proxies: dict[str, str] | None = None,
        cert: _t.CertType = None,
    )

Source from the content-addressed store, hash-verified

453 return _urllib3_request_context(request, verify, cert, self.poolmanager)
454
455 def get_connection_with_tls_context(
456 self,
457 request: PreparedRequest,
458 verify: _t.VerifyType,
459 proxies: dict[str, str] | None = None,
460 cert: _t.CertType = None,
461 ) -> HTTPConnectionPool:
462 """Returns a urllib3 connection for the given request and TLS settings.
463 This should not be called from user code, and is only exposed for use
464 when subclassing the :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
465
466 :param request:
467 The :class:`PreparedRequest <PreparedRequest>` object to be sent
468 over the connection.
469 :param verify:
470 Either a boolean, in which case it controls whether we verify the
471 server&#x27;s TLS certificate, or a string, in which case it must be a
472 path to a CA bundle to use.
473 :param proxies:
474 (optional) The proxies dictionary to apply to the request.
475 :param cert:
476 (optional) Any user-provided SSL certificate to be used for client
477 authentication (a.k.a., mTLS).
478 :rtype:
479 urllib3.HTTPConnectionPool
480 """
481 assert _is_prepared(request)
482
483 proxy = select_proxy(request.url, proxies)
484 try:
485 host_params, pool_kwargs = self.build_connection_pool_key_attributes(
486 request,
487 verify,
488 cert,
489 )
490 except ValueError as e:
491 raise InvalidURL(e, request=request)
492 if proxy:
493 proxy = prepend_scheme_if_needed(proxy, "http")
494 proxy_url = parse_url(proxy)
495 if not proxy_url.host:
496 raise InvalidProxyURL(
497 "Please check proxy URL. It is malformed "
498 "and could be missing the host."
499 )
500 proxy_manager = self.proxy_manager_for(proxy)
501 conn = proxy_manager.connection_from_host(
502 **host_params, pool_kwargs=pool_kwargs
503 )
504 else:
505 # Only scheme should be lower case
506 conn = self.poolmanager.connection_from_host(
507 **host_params, pool_kwargs=pool_kwargs
508 )
509
510 return conn
511
512 def get_connection(

Callers 1

sendMethod · 0.95

Calls 6

proxy_manager_forMethod · 0.95
select_proxyFunction · 0.85
InvalidURLClass · 0.85
prepend_scheme_if_neededFunction · 0.85
InvalidProxyURLClass · 0.85

Tested by

no test coverage detected