Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
proxy.py44 linesDownload Raw Back to util
1from __future__ import annotations2 3import typing4 5from .url import Url6 7if typing.TYPE_CHECKING:8    from ..connection import ProxyConfig9 10 11def connection_requires_http_tunnel(12    proxy_url: Url | None = None,13    proxy_config: ProxyConfig | None = None,14    destination_scheme: str | None = None,15) -> bool:16    """17    Returns True if the connection requires an HTTP CONNECT through the proxy.18 19    :param URL proxy_url:20        URL of the proxy.21    :param ProxyConfig proxy_config:22        Proxy configuration from poolmanager.py23    :param str destination_scheme:24        The scheme of the destination. (i.e https, http, etc)25    """26    # If we're not using a proxy, no way to use a tunnel.27    if proxy_url is None:28        return False29 30    # HTTP destinations never require tunneling, we always forward.31    if destination_scheme == "http":32        return False33 34    # Support for forwarding with HTTPS proxies and HTTPS destinations.35    if (36        proxy_url.scheme == "https"37        and proxy_config38        and proxy_config.use_forwarding_for_https39    ):40        return False41 42    # Otherwise always use a tunnel.43    return True44 
codekingpro/portable-devtools · Team Ai