diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a47c2b2..00d3ee39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Fixed +- The `https_proxy` environment variable is recognized as a synonym for + `HTTPS_PROXY`. + +### Added +- Added support for the `no_proxy` or `NO_PROXY` environment variables to specify + hosts that should not be accessed via proxy server. It's a comma-separated list + of host or domain suffixes. For example, specifying `example.com` will + bypass the proxy for example.com, host.example.com, etc. ## [1.20.0] - 2023-09-11 diff --git a/rsconnect/http_support.py b/rsconnect/http_support.py index 261b2e52..833d3d42 100644 --- a/rsconnect/http_support.py +++ b/rsconnect/http_support.py @@ -37,7 +37,7 @@ def _create_plain_connection(host_name, port, disable_tls_check, ca_data): def _get_proxy(): - proxyURL = os.getenv("HTTPS_PROXY") + proxyURL = os.getenv("https_proxy", os.getenv("HTTPS_PROXY")) if not proxyURL: return None, None, None, None parsed = urlparse(proxyURL) @@ -75,7 +75,12 @@ def _create_ssl_connection(host_name, port, disable_tls_check, ca_data): """ if ca_data is not None and disable_tls_check: raise ValueError("Cannot both disable TLS checking and provide a custom certificate") - _, _, proxyHost, proxyPort = _get_proxy() + + no_proxy = os.environ.get("no_proxy", os.environ.get("NO_PROXY", "#")) + if any([host_name.endswith(host) for host in no_proxy.split(",")]): + proxyHost, proxyPort = None, None + else: + _, _, proxyHost, proxyPort = _get_proxy() headers = _get_proxy_headers() timeout = get_request_timeout() logger.debug(f"The HTTPSConnection timeout is set to '{timeout}' seconds")