fixing proxy configuration with and without auth

This commit is contained in:
Pawan Paudel 2021-05-26 15:27:44 +05:45
parent 3a38afeef0
commit 81cbd5a588
1 changed files with 7 additions and 10 deletions

View File

@ -348,16 +348,13 @@ class Session(Closeable, SubListener, DealerClient.MessageListener):
@staticmethod
def _create_client(conf: Session.Configuration) -> requests.Session:
client = requests.Session()
if conf.proxyAuth and conf.proxyType is not Proxy.Type.DIRECT:
if conf.proxyAuth:
proxy_setting = [
conf.proxyUsername,
conf.proxyPassword,
conf.proxyAddress,
conf.proxyPort,
]
else:
proxy_setting = [conf.proxyAddress, conf.proxyPort]
if conf.proxyAddress and conf.proxyPort and conf.proxyType is not Proxy.Type.DIRECT:
proxy_setting = [
conf.proxyUsername,
conf.proxyPassword,
conf.proxyAddress,
conf.proxyPort,
]
client.proxies = {
"http": "{}:{}@{}:{}".format(*proxy_setting),
"https": "{}:{}@{}:{}".format(*proxy_setting),