annotate urllib3/util/proxy.py @ 8:832f269deeb0

planemo upload for repository https://toolrepo.galaxytrakr.org/view/jpayne/bioproject_to_srr_2/556cac4fb538
author jpayne
date Sun, 05 May 2024 23:47:10 -0400
parents 5eb2d5e3bf22
children
rev   line source
jpayne@7 1 from __future__ import annotations
jpayne@7 2
jpayne@7 3 import typing
jpayne@7 4
jpayne@7 5 from .url import Url
jpayne@7 6
jpayne@7 7 if typing.TYPE_CHECKING:
jpayne@7 8 from ..connection import ProxyConfig
jpayne@7 9
jpayne@7 10
jpayne@7 11 def connection_requires_http_tunnel(
jpayne@7 12 proxy_url: Url | None = None,
jpayne@7 13 proxy_config: ProxyConfig | None = None,
jpayne@7 14 destination_scheme: str | None = None,
jpayne@7 15 ) -> bool:
jpayne@7 16 """
jpayne@7 17 Returns True if the connection requires an HTTP CONNECT through the proxy.
jpayne@7 18
jpayne@7 19 :param URL proxy_url:
jpayne@7 20 URL of the proxy.
jpayne@7 21 :param ProxyConfig proxy_config:
jpayne@7 22 Proxy configuration from poolmanager.py
jpayne@7 23 :param str destination_scheme:
jpayne@7 24 The scheme of the destination. (i.e https, http, etc)
jpayne@7 25 """
jpayne@7 26 # If we're not using a proxy, no way to use a tunnel.
jpayne@7 27 if proxy_url is None:
jpayne@7 28 return False
jpayne@7 29
jpayne@7 30 # HTTP destinations never require tunneling, we always forward.
jpayne@7 31 if destination_scheme == "http":
jpayne@7 32 return False
jpayne@7 33
jpayne@7 34 # Support for forwarding with HTTPS proxies and HTTPS destinations.
jpayne@7 35 if (
jpayne@7 36 proxy_url.scheme == "https"
jpayne@7 37 and proxy_config
jpayne@7 38 and proxy_config.use_forwarding_for_https
jpayne@7 39 ):
jpayne@7 40 return False
jpayne@7 41
jpayne@7 42 # Otherwise always use a tunnel.
jpayne@7 43 return True