aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libpathod/pathod.py15
-rw-r--r--test/test_pathod.py8
2 files changed, 20 insertions, 3 deletions
diff --git a/libpathod/pathod.py b/libpathod/pathod.py
index 026986bb..e4a14193 100644
--- a/libpathod/pathod.py
+++ b/libpathod/pathod.py
@@ -42,9 +42,20 @@ class PathodHandler(tcp.BaseHandler):
method, path, httpversion = parts
headers = http.read_headers(self.rfile)
- content = http.read_http_body_request(
- self.rfile, self.wfile, headers, httpversion, None
+ try:
+ content = http.read_http_body_request(
+ 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
for i in self.server.anchors:
diff --git a/test/test_pathod.py b/test/test_pathod.py
index 1484efcd..86f37f01 100644
--- a/test/test_pathod.py
+++ b/test/test_pathod.py
@@ -1,6 +1,6 @@
import requests
from libpathod import pathod, test, version, pathoc
-from netlib import tcp
+from netlib import tcp, http
import tutils
class _TestApplication:
@@ -115,6 +115,12 @@ class _DaemonTests:
assert l["type"] == "error"
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):