Skip to content

Commit 5519c49

Browse files
committed
fix(proxy): remove no proxy
1 parent 3d6b214 commit 5519c49

File tree

3 files changed

+3
-52
lines changed

3 files changed

+3
-52
lines changed

SDK_Integration_zh.md

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
- [指定scheme](#指定scheme)
1515
- [Http(s)代理配置](#https代理配置)
1616
- [配置Http(s)代理](#配置https代理)
17-
- [配置No Proxy](#配置no-proxy)
1817
- [注意事项](#注意事项)
1918
- [忽略SSL验证](#忽略ssl验证)
2019
- [超时配置](#超时配置)
@@ -258,22 +257,6 @@ volcenginesdkcore.Configuration.set_default(configuration)
258257
api_instance = volcenginesdkecs.ECSApi()
259258
```
260259

261-
## 配置No Proxy
262-
263-
```python
264-
configuration = volcenginesdkcore.Configuration()
265-
configuration.ak = "Your AK"
266-
configuration.sk = "Your SK"
267-
268-
configuration.http_proxy = "http://your_proxy:8080"
269-
configuration.https_proxy = "http://your_proxy:8080"
270-
configuration.no_proxy = "host1_without_proxy,host2_without_proxy"
271-
272-
volcenginesdkcore.Configuration.set_default(configuration)
273-
274-
api_instance = volcenginesdkecs.ECSApi()
275-
```
276-
277260
## 注意事项
278261

279262
支持通过以下环境变量配置代理:

volcenginesdkcore/configuration.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ def __init__(self):
129129
self.proxy = None
130130
self.http_proxy = None
131131
self.https_proxy = None
132-
self.no_proxy = None
133132

134133
# Safe chars for path_param
135134
self.safe_chars_for_path_param = ''

volcenginesdkcore/rest.py

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,6 @@ def getheader(self, name, default=None):
4040
"""Returns a given response header."""
4141
return self.urllib3_response.getheader(name, default)
4242

43-
44-
def _get_no_proxy(configuration):
45-
n1 = os.environ.get('NO_PROXY')
46-
n2 = os.environ.get('no_proxy')
47-
if configuration.no_proxy:
48-
return configuration.no_proxy.split(',')
49-
elif n1:
50-
return n1.split(',')
51-
elif n2:
52-
return n2.split(',')
53-
return []
54-
55-
5643
class RESTClientObject(object):
5744

5845
def __init__(self, configuration, pools_size=4, maxsize=None):
@@ -62,18 +49,7 @@ def __init__(self, configuration, pools_size=4, maxsize=None):
6249
# maxsize is the number of requests to host that are allowed in parallel # noqa: E501
6350
# Custom SSL certificates and client certificates: http://urllib3.readthedocs.io/en/latest/advanced-usage.html # noqa: E501
6451

65-
self._configuration = configuration
66-
self._last_pm_proxy_url = None
67-
self._pools_size = pools_size
68-
self._maxsize = maxsize
69-
self._lock = threading.Lock()
70-
self.pool_manager = None
71-
72-
def __init_pool_manager(self, configuration, host, pools_size, maxsize):
73-
74-
proxy_url = self.__get_proxy(host)
75-
if proxy_url == self._last_pm_proxy_url and self.pool_manager:
76-
return
52+
proxy_url = self.__get_proxy(configuration)
7753

7854
# cert_reqs
7955
if configuration.verify_ssl:
@@ -134,12 +110,9 @@ def __init_pool_manager(self, configuration, host, pools_size, maxsize):
134110

135111
self._last_pm_proxy_url = proxy_url
136112

137-
def __get_proxy(self, host):
138-
configuration = self._configuration
113+
def __get_proxy(self, configuration):
139114
proxy_url = configuration.proxy
140-
if host in _get_no_proxy(configuration):
141-
proxy_url = None
142-
elif not configuration.proxy:
115+
if not proxy_url:
143116
if configuration.scheme == 'http':
144117
if configuration.http_proxy:
145118
proxy_url = configuration.http_proxy
@@ -205,10 +178,6 @@ def request(self, method, url, query_params=None, headers=None,
205178
if 'Content-Type' not in headers:
206179
headers['Content-Type'] = 'application/json'
207180

208-
host = headers.get('Host')
209-
with self._lock:
210-
self.__init_pool_manager(self._configuration, host, self._pools_size, self._maxsize)
211-
212181
try:
213182
# For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE`
214183
if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']:

0 commit comments

Comments
 (0)