mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2025-02-01 07:49:10 +00:00
Handle invalid content length headers.
This commit is contained in:
parent
7a49cdfef3
commit
8d8ede7e26
@ -42,9 +42,20 @@ class PathodHandler(tcp.BaseHandler):
|
|||||||
method, path, httpversion = parts
|
method, path, httpversion = parts
|
||||||
|
|
||||||
headers = http.read_headers(self.rfile)
|
headers = http.read_headers(self.rfile)
|
||||||
|
try:
|
||||||
content = http.read_http_body_request(
|
content = http.read_http_body_request(
|
||||||
self.rfile, self.wfile, headers, httpversion, None
|
self.rfile, self.wfile, headers, httpversion, None
|
||||||
)
|
)
|
||||||
|
except http.HttpError, s:
|
||||||
|
s = str(s)
|
||||||
|
self.info(s)
|
||||||
|
self.server.add_log(
|
||||||
|
dict(
|
||||||
|
type = "error",
|
||||||
|
msg = s
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
crafted = None
|
crafted = None
|
||||||
for i in self.server.anchors:
|
for i in self.server.anchors:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import requests
|
import requests
|
||||||
from libpathod import pathod, test, version, pathoc
|
from libpathod import pathod, test, version, pathoc
|
||||||
from netlib import tcp
|
from netlib import tcp, http
|
||||||
import tutils
|
import tutils
|
||||||
|
|
||||||
class _TestApplication:
|
class _TestApplication:
|
||||||
@ -115,6 +115,12 @@ class _DaemonTests:
|
|||||||
assert l["type"] == "error"
|
assert l["type"] == "error"
|
||||||
assert "foo" in l["msg"]
|
assert "foo" in l["msg"]
|
||||||
|
|
||||||
|
def test_invalid_body(self):
|
||||||
|
tutils.raises(http.HttpError, self.pathoc, "get:/:h'content-length'='foo'")
|
||||||
|
l = self.d.log()[0]
|
||||||
|
assert l["type"] == "error"
|
||||||
|
assert "Invalid" in l["msg"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TestDaemon(_DaemonTests):
|
class TestDaemon(_DaemonTests):
|
||||||
|
Loading…
Reference in New Issue
Block a user