From 848dfe66f525429494f15177e6d218cf21f5a5c2 Mon Sep 17 00:00:00 2001 From: Sergey Talash Date: Tue, 12 Sep 2023 14:37:54 +0600 Subject: [PATCH 1/3] Update http_support.py with NO_PROXY support --- rsconnect/http_support.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rsconnect/http_support.py b/rsconnect/http_support.py index 261b2e52..0661f4b2 100644 --- a/rsconnect/http_support.py +++ b/rsconnect/http_support.py @@ -75,7 +75,10 @@ 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() + if any([host_name.endswith(host) for host in os.environ.get('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") From 5f193afcb0b73ead9aa1722e37bd6512e7fb3e60 Mon Sep 17 00:00:00 2001 From: Michael Marchetti Date: Tue, 3 Oct 2023 11:52:43 -0400 Subject: [PATCH 2/3] allow lowercase env variable names --- rsconnect/http_support.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rsconnect/http_support.py b/rsconnect/http_support.py index 0661f4b2..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,9 @@ 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") - if any([host_name.endswith(host) for host in os.environ.get('NO_PROXY', '#').split(',')]): + + 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() From 3391353c3560abab1a4713f349d5e7dc28089860 Mon Sep 17 00:00:00 2001 From: Michael Marchetti Date: Tue, 3 Oct 2023 11:56:23 -0400 Subject: [PATCH 3/3] update changelog --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) 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