From 836c747bde1e7ee3334e9f8a68aaec9f89b4d7e8 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: Mon, 8 Jul 2024 18:02:48 +0800 Subject: [PATCH] fix --- .../LunaTranslator/network/libcurl/requests.py | 9 ++++----- LunaTranslator/LunaTranslator/network/requests_common.py | 2 ++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/LunaTranslator/LunaTranslator/network/libcurl/requests.py b/LunaTranslator/LunaTranslator/network/libcurl/requests.py index 765fd9d9..b98faed2 100644 --- a/LunaTranslator/LunaTranslator/network/libcurl/requests.py +++ b/LunaTranslator/LunaTranslator/network/libcurl/requests.py @@ -210,15 +210,14 @@ class Session(Sessionbase): cnt -= 1 if cnt == 0: break + else: + # 有proxy时,proxy也有可能有header. + headerb = "" else: headerb += _headerb resp.headers = self._update_header_cookie(headerb) - - if proxy: - resp.status_code = int(headerb[:-2].split(" ")[1]) - else: - resp.status_code = self._getStatusCode(curl) + resp.status_code = self._getStatusCode(curl) else: def WriteMemoryCallback(saver, contents, size, nmemb, userp): diff --git a/LunaTranslator/LunaTranslator/network/requests_common.py b/LunaTranslator/LunaTranslator/network/requests_common.py index 5b88a607..cad9890c 100644 --- a/LunaTranslator/LunaTranslator/network/requests_common.py +++ b/LunaTranslator/LunaTranslator/network/requests_common.py @@ -238,6 +238,8 @@ class Sessionbase: cookie = {} for line in headerstr.split("\r\n")[1:]: idx = line.find(": ") + if idx == -1: + continue if line[:idx].lower() == "set-cookie": _c = line[idx + 2 :].split("; ")[0] _idx = _c.find("=")