added configuration 'http_proxy' to allow the usage of a proxy

This commit is contained in:
mbohlool 2017-06-07 20:19:20 -07:00 committed by Sergi Almacellas Abellana
parent ab3fc54467
commit 0fc7bbbefc
2 changed files with 10 additions and 4 deletions

View File

@ -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"

11
rest.py
View File

@ -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,