From a655608d01a1ff44c8f6a3e0ab6ed07cb4e217c4 Mon Sep 17 00:00:00 2001 From: glide-the <2533736852@qq.com> Date: Wed, 4 Oct 2023 13:33:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=A3=E7=90=86=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/utils.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/server/utils.py b/server/utils.py index b6a3945b2..6f975e394 100644 --- a/server/utils.py +++ b/server/utils.py @@ -425,7 +425,7 @@ def set_httpx_config( if host not in no_proxy: no_proxy.append(host) os.environ["NO_PROXY"] = ",".join(no_proxy) - + # TODO: 简单的清除系统代理不是个好的选择,影响太多。似乎修改代理服务器的bypass列表更好。 # patch requests to use custom proxies instead of system settings # def _get_proxies(): @@ -506,10 +506,11 @@ def get_httpx_client( default_proxies.update({host: None}) # get proxies from system envionrent + # proxy not str empty string, None, False, 0, [] or {} default_proxies.update({ - "http://": os.environ.get("http_proxy"), - "https://": os.environ.get("https_proxy"), - "all://": os.environ.get("all_proxy"), + "http://": os.environ.get("http_proxy") if len(os.environ.get("http_proxy").strip()) > 0 else None, + "https://": os.environ.get("https_proxy") if len(os.environ.get("https_proxy").strip()) > 0 else None, + "all://": os.environ.get("all_proxy") if len(os.environ.get("all_proxy").strip()) > 0 else None, }) for host in os.environ.get("no_proxy", "").split(","): if host := host.strip(): @@ -524,6 +525,7 @@ def get_httpx_client( # construct Client kwargs.update(timeout=timeout, proxies=default_proxies) + print(kwargs) if use_async: return httpx.AsyncClient(**kwargs) else: