From 217fcfd1b2a9cea1d31bde764506ad9cdd773894 Mon Sep 17 00:00:00 2001 From: InfinityPacer Date: Fri, 10 Apr 2026 17:25:11 +0800 Subject: [PATCH] fix(http): close non-success responses safely --- app/utils/http.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/utils/http.py b/app/utils/http.py index c4d91d4c..7ac0a417 100644 --- a/app/utils/http.py +++ b/app/utils/http.py @@ -161,7 +161,7 @@ class RequestUtils: response = self.request(method=method, url=url, **kwargs) yield response finally: - if response: + if response is not None: try: response.close() except Exception as e: @@ -280,7 +280,7 @@ class RequestUtils: try: yield response finally: - if response: + if response is not None: response.close() def post_res(self, @@ -654,7 +654,7 @@ class AsyncRequestUtils: response = await self.request(method=method, url=url, **kwargs) yield response finally: - if response: + if response is not None: try: await response.aclose() except Exception as e: @@ -785,7 +785,7 @@ class AsyncRequestUtils: try: yield response finally: - if response: + if response is not None: await response.aclose() async def post_res(self,