Skip to content

Commit

Permalink
add HTTPSConnection.proxy_is_tunneling
Browse files Browse the repository at this point in the history
  • Loading branch information
abebeos committed Jan 18, 2024
1 parent bbba487 commit 68e55ae
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/urllib3/connection.py
Expand Up @@ -272,6 +272,13 @@ def proxy_is_forwarding(self) -> bool:
"""
return bool(self.proxy) and self._tunnel_host is None

@property
def proxy_is_tunneling(self) -> bool:
"""
Return True if a tunneling proxy is configured, else return False
"""
return self._tunnel_host is not None

def close(self) -> None:
try:
super().close()
Expand Down Expand Up @@ -618,7 +625,7 @@ def connect(self) -> None:
tls_in_tls = False

# Do we need to establish a tunnel?
if self._tunnel_host is not None:
if self.proxy_is_tunneling:
# We're tunneling to an HTTPS origin so need to do TLS-in-TLS.
if self._tunnel_scheme == "https":
# _connect_tls_proxy will verify and assign proxy_is_verified
Expand All @@ -632,7 +639,7 @@ def connect(self) -> None:

self._tunnel() # type: ignore[attr-defined]
# Override the host with the one we're requesting data from.
server_hostname = self._tunnel_host
server_hostname = self._tunnel_host # type: ignore[assignment]

if self.server_hostname is not None:
server_hostname = self.server_hostname
Expand Down

0 comments on commit 68e55ae

Please sign in to comment.