From 4995c8b19ac6e0bd4964ebbcdc8dd905da3e88b9 Mon Sep 17 00:00:00 2001 From: HibiKier <775757368@qq.com> Date: Thu, 16 Oct 2025 17:28:09 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(http=5Futils):=20=E6=94=B9?= =?UTF-8?q?=E8=BF=9BHTTP=E9=94=99=E8=AF=AF=E5=A4=84=E7=90=86=EF=BC=8C?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E8=AF=B7=E6=B1=82=E5=A4=B1=E8=B4=A5=E7=9A=84?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E7=A0=81=E5=92=8C=E5=93=8D=E5=BA=94=E5=86=85?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zhenxun/utils/http_utils.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/zhenxun/utils/http_utils.py b/zhenxun/utils/http_utils.py index 0c98c4fe..8c8e97eb 100644 --- a/zhenxun/utils/http_utils.py +++ b/zhenxun/utils/http_utils.py @@ -262,13 +262,19 @@ class AsyncHttpx: "AsyncHttpx:FallbackExecutor", ) return result - except HTTPStatusError as e: - exceptions.append(e) - logger.debug( - f"请求失败: {url} {e.response.status_code} {e.response.text}", - "AsyncHttpx:FallbackExecutor", - ) except Exception as e: + if isinstance(e, HTTPStatusError): + status = getattr(e.response, "status_code", "?") + try: + body_text = getattr(e.response, "text", None) + if body_text is not None and len(body_text) > 2000: + body_text = body_text[:2000] + "...(truncated)" + except Exception: + body_text = "" + logger.debug( + f"请求失败: {url} {status} {body_text}", + "AsyncHttpx:FallbackExecutor", + ) exceptions.append(e) if url != url_list[-1]: logger.warning(