From a5ab7306692cfc6e2599f8b7e810c78cc59be389 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Tue, 9 Jul 2024 01:05:57 +0800 Subject: [PATCH] zstd --- LunaTranslator/LunaTranslator/network/libcurl/requester.py | 3 +++ LunaTranslator/LunaTranslator/requests.py | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/LunaTranslator/LunaTranslator/network/libcurl/requester.py b/LunaTranslator/LunaTranslator/network/libcurl/requester.py index 3c8e4836..e03de434 100644 --- a/LunaTranslator/LunaTranslator/network/libcurl/requester.py +++ b/LunaTranslator/LunaTranslator/network/libcurl/requester.py @@ -54,6 +54,9 @@ def ExceptionFilter(func): class Requester(Requester_common): + + Accept_Encoding = "gzip, deflate, br, zstd" + def raise_for_status(self): if self.last_error: raise CURLException(self.last_error) diff --git a/LunaTranslator/LunaTranslator/requests.py b/LunaTranslator/LunaTranslator/requests.py index 2549b7b3..4a9aa24f 100644 --- a/LunaTranslator/LunaTranslator/requests.py +++ b/LunaTranslator/LunaTranslator/requests.py @@ -119,6 +119,7 @@ class ResponseBase: class Requester_common: + Accept_Encoding = "gzip, deflate, br" def request(self, *argc) -> ResponseBase: ... @@ -277,7 +278,9 @@ class Session: verify=False, cert=None, ): + requester = self.loadrequester() _h = self.headers.copy() + _h.update({"Accept-Encoding": requester.Accept_Encoding}) if headers: _h.update(headers) headers = _h @@ -307,7 +310,7 @@ class Session: timeout = None if cookies: self.cookies.update(cookies) - response = self.loadrequester().request( + response = requester.request( method, scheme, server,