Skip to content

Commit 0fc7bbb

Browse files
mbohloolSergi Almacellas Abellana
authored andcommitted
added configuration 'http_proxy' to allow the usage of a proxy
1 parent ab3fc54 commit 0fc7bbb

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

configuration.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,14 @@ def __init__(self):
8282
# check host name
8383
# Set this to True/False to enable/disable SSL hostname verification.
8484
self.assert_hostname = None
85-
8685
# urllib3 connection pool's maximum number of connections saved
8786
# per pool. Increasing this is useful for cases when you are
8887
# making a lot of possibly parallel requests to the same host,
8988
# which is often the case here.
9089
# When set to `None`, will default to whatever urllib3 uses
9190
self.connection_pool_maxsize = None
91+
# http proxy setting
92+
self.http_proxy_url = None
9293

9394
# WebSocket subprotocol to use for exec and portforward.
9495
self.ws_streaming_protocol = "v4.channel.k8s.io"

rest.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,14 @@ def __init__(self, pools_size=4, config=configuration):
106106
kwargs['assert_hostname'] = config.assert_hostname
107107

108108
# https pool manager
109-
self.pool_manager = urllib3.PoolManager(
110-
**kwargs
111-
)
109+
if config.http_proxy_url is not None:
110+
self.pool_manager = urllib3.proxy_from_url(
111+
config.http_proxy_url, **kwargs
112+
)
113+
else:
114+
self.pool_manager = urllib3.PoolManager(
115+
**kwargs
116+
)
112117

113118
def request(self, method, url, query_params=None, headers=None,
114119
body=None, post_params=None, _preload_content=True,

0 commit comments

Comments
 (0)