From b8f6b12314358b34478fcf861a1d7d2d00cabd05 Mon Sep 17 00:00:00 2001 From: yym68686 <31803242+yym68686@users.noreply.github.com> Date: Tue, 18 Oct 2022 21:35:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=20Content-Length=20=E4=B8=8E=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E4=BD=93=E7=9C=9F=E5=AE=9E=E9=95=BF=E5=BA=A6=E5=AF=B9?= =?UTF-8?q?=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 避免 Content-Length 与请求体真实长度不相等造成请求失败。 --- HackRequests/HackRequests.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/HackRequests/HackRequests.py b/HackRequests/HackRequests.py index 8706098..e6ed793 100644 --- a/HackRequests/HackRequests.py +++ b/HackRequests/HackRequests.py @@ -218,6 +218,8 @@ def httpraw(self, raw: str, **kwargs): try: conn.putrequest(method, path, skip_host=True, skip_accept_encoding=True) for k, v in headers.items(): + if k == "Content-Length": + v = conn._get_content_length(body, method) conn.putheader(k, v) if body and "Content-Length" not in headers and "Transfer-Encoding" not in headers: length = conn._get_content_length(body, method)