[python/asyncio] fix passing proxy parameters to aiohttp (#5943)

This commit is contained in:
Tomasz Prus
2020-04-16 03:16:08 +02:00
committed by GitHub
parent 91cfabdad2
commit 7a0242311f
3 changed files with 35 additions and 18 deletions

View File

@@ -73,16 +73,13 @@ class RESTClientObject(object):
ssl=ssl_context
)
self.proxy = configuration.proxy
self.proxy_headers = configuration.proxy_headers
# https pool manager
if configuration.proxy:
self.pool_manager = aiohttp.ClientSession(
connector=connector,
proxy=configuration.proxy
)
else:
self.pool_manager = aiohttp.ClientSession(
connector=connector
)
self.pool_manager = aiohttp.ClientSession(
connector=connector
)
async def close(self):
await self.pool_manager.close()
@@ -130,6 +127,11 @@ class RESTClientObject(object):
"headers": headers
}
if self.proxy:
args["proxy"] = self.proxy
if self.proxy_headers:
args["proxy_headers"] = self.proxy_headers
if query_params:
args["url"] += '?' + urlencode(query_params)