From 0fc7bbbefc6ad9dc52aa77d1219c714d4388f316 Mon Sep 17 00:00:00 2001 From: mbohlool Date: Wed, 7 Jun 2017 20:19:20 -0700 Subject: [PATCH] added configuration 'http_proxy' to allow the usage of a proxy --- configuration.py | 3 ++- rest.py | 11 ++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/configuration.py b/configuration.py index 4377eb8f7..3e211d117 100644 --- a/configuration.py +++ b/configuration.py @@ -82,13 +82,14 @@ class ConfigurationObject(object): # check host name # Set this to True/False to enable/disable SSL hostname verification. self.assert_hostname = None - # urllib3 connection pool's maximum number of connections saved # per pool. Increasing this is useful for cases when you are # making a lot of possibly parallel requests to the same host, # which is often the case here. # When set to `None`, will default to whatever urllib3 uses self.connection_pool_maxsize = None + # http proxy setting + self.http_proxy_url = None # WebSocket subprotocol to use for exec and portforward. self.ws_streaming_protocol = "v4.channel.k8s.io" diff --git a/rest.py b/rest.py index 5c2b39ff2..2dd18f20e 100644 --- a/rest.py +++ b/rest.py @@ -106,9 +106,14 @@ class RESTClientObject(object): kwargs['assert_hostname'] = config.assert_hostname # https pool manager - self.pool_manager = urllib3.PoolManager( - **kwargs - ) + if config.http_proxy_url is not None: + self.pool_manager = urllib3.proxy_from_url( + config.http_proxy_url, **kwargs + ) + else: + self.pool_manager = urllib3.PoolManager( + **kwargs + ) def request(self, method, url, query_params=None, headers=None, body=None, post_params=None, _preload_content=True,