Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

proxy.py 1.1KB

1 year ago
12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. from __future__ import annotations
  2. import typing
  3. from .url import Url
  4. if typing.TYPE_CHECKING:
  5. from ..connection import ProxyConfig
  6. def connection_requires_http_tunnel(
  7. proxy_url: Url | None = None,
  8. proxy_config: ProxyConfig | None = None,
  9. destination_scheme: str | None = None,
  10. ) -> bool:
  11. """
  12. Returns True if the connection requires an HTTP CONNECT through the proxy.
  13. :param URL proxy_url:
  14. URL of the proxy.
  15. :param ProxyConfig proxy_config:
  16. Proxy configuration from poolmanager.py
  17. :param str destination_scheme:
  18. The scheme of the destination. (i.e https, http, etc)
  19. """
  20. # If we're not using a proxy, no way to use a tunnel.
  21. if proxy_url is None:
  22. return False
  23. # HTTP destinations never require tunneling, we always forward.
  24. if destination_scheme == "http":
  25. return False
  26. # Support for forwarding with HTTPS proxies and HTTPS destinations.
  27. if (
  28. proxy_url.scheme == "https"
  29. and proxy_config
  30. and proxy_config.use_forwarding_for_https
  31. ):
  32. return False
  33. # Otherwise always use a tunnel.
  34. return True