Skip to content

Commit f4def0c

Browse files
authored
Merge pull request #488 from rstudio/no-proxy
Add NO_PROXY support
2 parents 8774dc6 + 2b8dc59 commit f4def0c

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file.
33

44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
## Unreleased
7+
8+
### Fixed
9+
- The `https_proxy` environment variable is recognized as a synonym for
10+
`HTTPS_PROXY`.
11+
12+
### Added
13+
- Added support for the `no_proxy` or `NO_PROXY` environment variables to specify
14+
hosts that should not be accessed via proxy server. It's a comma-separated list
15+
of host or domain suffixes. For example, specifying `example.com` will
16+
bypass the proxy for example.com, host.example.com, etc.
617

718
## [1.20.0] - 2023-09-11
819

rsconnect/http_support.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def _create_plain_connection(host_name, port, disable_tls_check, ca_data):
3737

3838

3939
def _get_proxy():
40-
proxyURL = os.getenv("HTTPS_PROXY")
40+
proxyURL = os.getenv("https_proxy", os.getenv("HTTPS_PROXY"))
4141
if not proxyURL:
4242
return None, None, None, None
4343
parsed = urlparse(proxyURL)
@@ -75,7 +75,12 @@ def _create_ssl_connection(host_name, port, disable_tls_check, ca_data):
7575
"""
7676
if ca_data is not None and disable_tls_check:
7777
raise ValueError("Cannot both disable TLS checking and provide a custom certificate")
78-
_, _, proxyHost, proxyPort = _get_proxy()
78+
79+
no_proxy = os.environ.get("no_proxy", os.environ.get("NO_PROXY", "#"))
80+
if any([host_name.endswith(host) for host in no_proxy.split(",")]):
81+
proxyHost, proxyPort = None, None
82+
else:
83+
_, _, proxyHost, proxyPort = _get_proxy()
7984
headers = _get_proxy_headers()
8085
timeout = get_request_timeout()
8186
logger.debug(f"The HTTPSConnection timeout is set to '{timeout}' seconds")

0 commit comments

Comments
 (0)