Skip to content
This repository was archived by the owner on Mar 13, 2022. It is now read-only.

Commit dd68a0a

Browse files
committed
added configuration 'http_proxy' to allow the usage of a proxy
1 parent d58dcea commit dd68a0a

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

configuration.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ def __init__(self):
8989
# Set this to True/False to enable/disable SSL hostname verification.
9090
self.assert_hostname = None
9191

92+
# http proxy setting
93+
self.http_proxy_url = None
94+
95+
9296
@property
9397
def logger_file(self):
9498
"""

rest.py

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

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

114119
def request(self, method, url, query_params=None, headers=None,
115120
body=None, post_params=None, _preload_content=True, _request_timeout=None):

0 commit comments

Comments
 (0)