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

Method get_connection

src/requests/adapters.py:512–553  ·  view source on GitHub ↗

DEPRECATED: 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 :cl

(
        self, url: str, proxies: dict[str, str] | None = None
    )

Source from the content-addressed store, hash-verified

510 return conn
511
512 def get_connection(
513 self, url: str, proxies: dict[str, str] | None = None
514 ) -> HTTPConnectionPool:
515 """DEPRECATED: Users should move to `get_connection_with_tls_context`
516 for all subclasses of HTTPAdapter using Requests>=2.32.2.
517
518 Returns a urllib3 connection for the given URL. This should not be
519 called from user code, and is only exposed for use when subclassing the
520 :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.
521
522 :param url: The URL to connect to.
523 :param proxies: (optional) A Requests-style dictionary of proxies used on this request.
524 :rtype: urllib3.HTTPConnectionPool
525 """
526 warnings.warn(
527 (
528 "`get_connection` has been deprecated in favor of "
529 "`get_connection_with_tls_context`. Custom HTTPAdapter subclasses "
530 "will need to migrate for Requests>=2.32.2. Please see "
531 "https://github.com/psf/requests/pull/6710 for more details."
532 ),
533 DeprecationWarning,
534 )
535 proxy = select_proxy(url, proxies)
536
537 if proxy:
538 proxy = prepend_scheme_if_needed(proxy, "http")
539 proxy_url = parse_url(proxy)
540 if not proxy_url.host:
541 raise InvalidProxyURL(
542 "Please check proxy URL. It is malformed "
543 "and could be missing the host."
544 )
545 proxy_manager = self.proxy_manager_for(proxy)
546 conn = proxy_manager.connection_from_url(url)
547 else:
548 # Only scheme should be lower case
549 parsed = urlparse(url)
550 url = parsed.geturl()
551 conn = self.poolmanager.connection_from_url(url)
552
553 return conn
554
555 def close(self) -> None:
556 """Disposes of any internal state.

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected