Skip to content

Commit 13cab43

Browse files
authored
Merge pull request #296 from carbonblack/CBAPI-2608-proxy-connection
[CBAPI-2608] Include credentials.use_custom_proxy_session
2 parents ef04339 + 0a12ddd commit 13cab43

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/cbapi/connection.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ def __init__(self, credentials, integration_name=None, timeout=None, max_retries
152152
integration_name (str): The integration name being used.
153153
timeout (int): The timeout value to use for HTTP requests on this connection.
154154
max_retries (int): The maximum number of times to retry a request.
155+
proxy_session (requests.Session) custom session to be used
155156
**pool_kwargs: Additional arguments to be used to initialize connection pooling.
156157
157158
Raises:
@@ -186,8 +187,10 @@ def __init__(self, credentials, integration_name=None, timeout=None, max_retries
186187
self.token_header = {'X-Auth-Token': self.token, 'User-Agent': user_agent}
187188
if proxy_session:
188189
self.session = proxy_session
190+
credentials.use_custom_proxy_session = True
189191
else:
190192
self.session = requests.Session()
193+
credentials.use_custom_proxy_session = False
191194

192195
self._timeout = timeout
193196

@@ -207,7 +210,10 @@ def __init__(self, credentials, integration_name=None, timeout=None, max_retries
207210
self.session.mount(self.server, tls_adapter)
208211

209212
self.proxies = {}
210-
if credentials.ignore_system_proxy: # see https://github.com/kennethreitz/requests/issues/879
213+
if credentials.use_custom_proxy_session:
214+
# get the custom session proxies
215+
self.proxies = self.session.proxies
216+
elif credentials.ignore_system_proxy: # see https://github.com/kennethreitz/requests/issues/879
211217
# Unfortunately, requests will look for any proxy-related environment variables and use those anyway. The
212218
# only way to solve this without side effects, is passing in empty strings for 'http' and 'https':
213219
self.proxies = {

0 commit comments

Comments
 (0)