From fd5fda980eb6c0310ef904bc6a78cf158f3bea36 Mon Sep 17 00:00:00 2001 From: jue0115 <46835138+jue0115@users.noreply.github.com> Date: Sat, 7 Oct 2023 18:38:33 +0800 Subject: [PATCH] fix http(s) fix http https --- backend/src/module/network/request_url.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/backend/src/module/network/request_url.py b/backend/src/module/network/request_url.py index d4e17395..c6148074 100644 --- a/backend/src/module/network/request_url.py +++ b/backend/src/module/network/request_url.py @@ -87,11 +87,20 @@ class RequestURL: self.session = requests.Session() if settings.proxy.enable: if "http" in settings.proxy.type: - url = f"{settings.proxy.type}://{settings.proxy.host}:{settings.proxy.port}" - self.session.proxies = { - "https": url, - "http": url, - } + if settings.proxy.username: + username=settings.proxy.username + password=settings.proxy.password + url = f"http://{username}:{password}@{settings.proxy.host}:{settings.proxy.port}" + self.session.proxies = { + "http": url, + "https": url, + } + else: + url = f"http://{settings.proxy.host}:{settings.proxy.port}" + self.session.proxies = { + "http": url, + "https": url, + } elif settings.proxy.type == "socks5": self._socks5_proxy = True socks.set_default_proxy(