mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2025-02-01 15:55:28 +00:00
Don't specify Content-Length on empty content.
Sometimes, mitmproxy would specify a content-length header value of 0 when content was empty. Some rare servers (like piratebay.org) would barf on this.
This commit is contained in:
parent
efa98d514c
commit
2fe54d17df
@ -528,10 +528,10 @@ class Request(HTTPMsg):
|
|||||||
if not 'host' in headers:
|
if not 'host' in headers:
|
||||||
headers["host"] = [utils.hostport(self.scheme, self.host, self.port)]
|
headers["host"] = [utils.hostport(self.scheme, self.host, self.port)]
|
||||||
content = self.content
|
content = self.content
|
||||||
if content is None:
|
if content:
|
||||||
content = ""
|
|
||||||
else:
|
|
||||||
headers["content-length"] = [str(len(content))]
|
headers["content-length"] = [str(len(content))]
|
||||||
|
else:
|
||||||
|
content = ""
|
||||||
if self.close:
|
if self.close:
|
||||||
headers["connection"] = ["close"]
|
headers["connection"] = ["close"]
|
||||||
if not _proxy:
|
if not _proxy:
|
||||||
@ -698,10 +698,10 @@ class Response(HTTPMsg):
|
|||||||
['proxy-connection', 'connection', 'keep-alive', 'transfer-encoding']
|
['proxy-connection', 'connection', 'keep-alive', 'transfer-encoding']
|
||||||
)
|
)
|
||||||
content = self.content
|
content = self.content
|
||||||
if content is None:
|
if content:
|
||||||
content = ""
|
|
||||||
else:
|
|
||||||
headers["content-length"] = [str(len(content))]
|
headers["content-length"] = [str(len(content))]
|
||||||
|
else:
|
||||||
|
content = ""
|
||||||
if self.request.client_conn.close:
|
if self.request.client_conn.close:
|
||||||
headers["connection"] = ["close"]
|
headers["connection"] = ["close"]
|
||||||
proto = "HTTP/1.1 %s %s"%(self.code, str(self.msg))
|
proto = "HTTP/1.1 %s %s"%(self.code, str(self.msg))
|
||||||
|
Loading…
Reference in New Issue
Block a user