Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Hörist <philipp@hoerist.com>2023-04-10 23:41:52 +0300
committerPhilipp Hörist <philipp@hoerist.com>2023-04-11 00:31:59 +0300
commit229fc4bcd5e32d37ba7f6e843ea20485766c4d3f (patch)
tree12b890bb3d2f141b1bf52a19b4b78a90b3cd6ef3
parent253fb678f95261733a4e03638a2bc33d9f1e6814 (diff)
refactor: HTTP: Allow passing proxy when creating session
-rw-r--r--gajim/common/util/http.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/gajim/common/util/http.py b/gajim/common/util/http.py
index 9cec1cab1..9bb93170a 100644
--- a/gajim/common/util/http.py
+++ b/gajim/common/util/http.py
@@ -16,19 +16,24 @@ from typing import Optional
from nbxmpp.http import HTTPRequest
from nbxmpp.http import HTTPSession
+from nbxmpp.structs import ProxyData
from gajim.common import app
from gajim.common.helpers import determine_proxy
from gajim.common.helpers import get_account_proxy
-def create_http_session(account: Optional[str] = None) -> HTTPSession:
+def create_http_session(account: Optional[str] = None,
+ proxy: Optional[ProxyData] = None
+ ) -> HTTPSession:
+
session = HTTPSession(user_agent=f'Gajim {app.version}')
- if account is None:
- proxy = determine_proxy()
- else:
- proxy = get_account_proxy(account)
+ if proxy is None:
+ if account is not None:
+ proxy = get_account_proxy(account)
+ else:
+ proxy = determine_proxy()
if proxy is not None:
session.set_proxy_resolver(proxy.get_resolver())