aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/test_context.py2
-rw-r--r--examples/test_setup.py2
-rw-r--r--examples/test_setupall.py2
-rw-r--r--libpathod/pathoc.py2
-rw-r--r--libpathod/pathod.py2
-rw-r--r--libpathod/protocols/http.py4
-rw-r--r--test/test_app.py24
-rw-r--r--test/test_pathoc.py6
-rw-r--r--test/test_pathod.py10
-rw-r--r--test/tutils.py8
10 files changed, 33 insertions, 29 deletions
diff --git a/examples/test_context.py b/examples/test_context.py
index 7c0386c1..1f0a7f8b 100644
--- a/examples/test_context.py
+++ b/examples/test_context.py
@@ -16,7 +16,7 @@ def test_simple():
# Check the returned data
assert r.status_code == 200
- assert len(r.content) == 100
+ assert len(r.body) == 100
# Check pathod's internal log
log = d.last_log()["request"]
diff --git a/examples/test_setup.py b/examples/test_setup.py
index 39bd96b9..c6e52d00 100644
--- a/examples/test_setup.py
+++ b/examples/test_setup.py
@@ -24,7 +24,7 @@ class Test:
# Check the returned data
assert r.status_code == 200
- assert len(r.content) == 100
+ assert len(r.body) == 100
# Check pathod's internal log
log = self.d.last_log()["request"]
diff --git a/examples/test_setupall.py b/examples/test_setupall.py
index 631caa76..ddf4d905 100644
--- a/examples/test_setupall.py
+++ b/examples/test_setupall.py
@@ -29,7 +29,7 @@ class Test:
# Check the returned data
assert r.status_code == 200
- assert len(r.content) == 100
+ assert len(r.body) == 100
# Check pathod's internal log
log = self.d.last_log()["request"]
diff --git a/libpathod/pathoc.py b/libpathod/pathoc.py
index c1bca07f..e93e6208 100644
--- a/libpathod/pathoc.py
+++ b/libpathod/pathoc.py
@@ -417,7 +417,7 @@ class Pathoc(tcp.TCPClient):
finally:
if resp:
lg("<< %s %s: %s bytes" % (
- resp.status_code, utils.xrepr(resp.msg), len(resp.content)
+ resp.status_code, utils.xrepr(resp.msg), len(resp.body)
))
if resp.status_code in self.ignorecodes:
lg.suppress()
diff --git a/libpathod/pathod.py b/libpathod/pathod.py
index f8607cca..6f25d0c8 100644
--- a/libpathod/pathod.py
+++ b/libpathod/pathod.py
@@ -212,7 +212,7 @@ class PathodHandler(tcp.BaseHandler):
spec = anchor_gen.next()
if self.use_http2 and isinstance(spec, language.http2.Response):
- spec.stream_id = stream_id
+ spec.stream_id = req.stream_id
lg("crafting spec: %s" % spec)
nexthandler, retlog["response"] = self.http_serve_crafted(
diff --git a/libpathod/protocols/http.py b/libpathod/protocols/http.py
index 43ef0799..d6017882 100644
--- a/libpathod/protocols/http.py
+++ b/libpathod/protocols/http.py
@@ -13,7 +13,7 @@ class HTTPProtocol:
def make_error_response(self, reason, body):
return language.http.make_error_response(reason, body)
- def handle_http_app(self, method, path, headers, content, lg):
+ def handle_http_app(self, method, path, headers, body, lg):
"""
Handle a request to the built-in app.
"""
@@ -25,7 +25,7 @@ class HTTPProtocol:
msg="Access denied: web interface disabled"
)
lg("app: %s %s" % (method, path))
- req = wsgi.Request("http", method, path, headers, content)
+ req = wsgi.Request("http", method, path, headers, body)
flow = wsgi.Flow(self.pathod_handler.address, req)
sn = self.pathod_handler.connection.getsockname()
a = wsgi.WSGIAdaptor(
diff --git a/test/test_app.py b/test/test_app.py
index 4536db8e..4571617f 100644
--- a/test/test_app.py
+++ b/test/test_app.py
@@ -7,7 +7,7 @@ class TestApp(tutils.DaemonTests):
def test_index(self):
r = self.getpath("/")
assert r.status_code == 200
- assert r.content
+ assert r.body
def test_about(self):
r = self.getpath("/about")
@@ -38,48 +38,48 @@ class TestApp(tutils.DaemonTests):
def test_response_preview(self):
r = self.getpath("/response_preview", params=dict(spec="200"))
assert r.status_code == 200
- assert 'Response' in r.content
+ assert 'Response' in r.body
r = self.getpath("/response_preview", params=dict(spec="foo"))
assert r.status_code == 200
- assert 'Error' in r.content
+ assert 'Error' in r.body
r = self.getpath("/response_preview", params=dict(spec="200:b@100m"))
assert r.status_code == 200
- assert "too large" in r.content
+ assert "too large" in r.body
r = self.getpath("/response_preview", params=dict(spec="200:b@5k"))
assert r.status_code == 200
- assert 'Response' in r.content
+ assert 'Response' in r.body
r = self.getpath(
"/response_preview",
params=dict(
spec="200:b<nonexistent"))
assert r.status_code == 200
- assert 'File access denied' in r.content
+ assert 'File access denied' in r.body
r = self.getpath("/response_preview", params=dict(spec="200:b<file"))
assert r.status_code == 200
- assert 'testfile' in r.content
+ assert 'testfile' in r.body
def test_request_preview(self):
r = self.getpath("/request_preview", params=dict(spec="get:/"))
assert r.status_code == 200
- assert 'Request' in r.content
+ assert 'Request' in r.body
r = self.getpath("/request_preview", params=dict(spec="foo"))
assert r.status_code == 200
- assert 'Error' in r.content
+ assert 'Error' in r.body
r = self.getpath("/request_preview", params=dict(spec="get:/:b@100m"))
assert r.status_code == 200
- assert "too large" in r.content
+ assert "too large" in r.body
r = self.getpath("/request_preview", params=dict(spec="get:/:b@5k"))
assert r.status_code == 200
- assert 'Request' in r.content
+ assert 'Request' in r.body
r = self.getpath("/request_preview", params=dict(spec=""))
assert r.status_code == 200
- assert 'empty spec' in r.content
+ assert 'empty spec' in r.body
diff --git a/test/test_pathoc.py b/test/test_pathoc.py
index e9d1e6ab..215f691b 100644
--- a/test/test_pathoc.py
+++ b/test/test_pathoc.py
@@ -45,7 +45,7 @@ class _TestDaemon:
)
c.connect()
resp = c.request("get:/api/info")
- assert tuple(json.loads(resp.content)["version"]) == version.IVERSION
+ assert tuple(json.loads(resp.body)["version"]) == version.IVERSION
def tval(
self,
@@ -105,7 +105,7 @@ class TestDaemonSSL(_TestDaemon):
c.connect()
c.request("get:/p/200")
r = c.request("get:/api/log")
- d = json.loads(r.content)
+ d = json.loads(r.body)
assert d["log"][0]["request"]["sni"] == "foobar.com"
def test_showssl(self):
@@ -121,7 +121,7 @@ class TestDaemonSSL(_TestDaemon):
c.connect()
c.request("get:/p/200")
r = c.request("get:/api/log")
- d = json.loads(r.content)
+ d = json.loads(r.body)
assert d["log"][0]["request"]["clientcert"]["keyinfo"]
def test_http2_without_ssl(self):
diff --git a/test/test_pathod.py b/test/test_pathod.py
index c8060594..4adc9c22 100644
--- a/test/test_pathod.py
+++ b/test/test_pathod.py
@@ -51,7 +51,7 @@ class TestNoApi(tutils.DaemonTests):
assert self.getpath("/log").status_code == 404
r = self.getpath("/")
assert r.status_code == 200
- assert not "Log" in r.content
+ assert not "Log" in r.body
class TestNotAfterConnect(tutils.DaemonTests):
@@ -119,7 +119,7 @@ class TestNocraft(tutils.DaemonTests):
def test_nocraft(self):
r = self.get(r"200:b'\xf0'")
assert r.status_code == 800
- assert "Crafting disabled" in r.content
+ assert "Crafting disabled" in r.body
class CommonTests(tutils.DaemonTests):
@@ -152,7 +152,7 @@ class CommonTests(tutils.DaemonTests):
def test_disconnect(self):
rsp = self.get("202:b@100k:d200")
- assert len(rsp.content) < 200
+ assert len(rsp.body) < 200
def test_parserr(self):
rsp = self.get("400:msg,b:")
@@ -161,7 +161,7 @@ class CommonTests(tutils.DaemonTests):
def test_static(self):
rsp = self.get("200:b<file")
assert rsp.status_code == 200
- assert rsp.content.strip() == "testfile"
+ assert rsp.body.strip() == "testfile"
def test_anchor(self):
rsp = self.getpath("anchor/foo")
@@ -201,7 +201,7 @@ class CommonTests(tutils.DaemonTests):
def test_source_access_denied(self):
rsp = self.get("200:b</foo")
assert rsp.status_code == 800
- assert "File access denied" in rsp.content
+ assert "File access denied" in rsp.body
def test_proxy(self):
r, _ = self.pathoc([r"get:'http://foo.com/p/202':da"])
diff --git a/test/tutils.py b/test/tutils.py
index f7fcc312..a728e852 100644
--- a/test/tutils.py
+++ b/test/tutils.py
@@ -62,7 +62,7 @@ class DaemonTests(object):
def getpath(self, path, params=None):
scheme = "https" if self.ssl else "http"
- return requests.get(
+ resp = requests.get(
"%s://localhost:%s/%s" % (
scheme,
self.d.port,
@@ -71,9 +71,13 @@ class DaemonTests(object):
verify=False,
params=params
)
+ resp.body = resp.content
+ return resp
def get(self, spec):
- return requests.get(self.d.p(spec), verify=False)
+ resp = requests.get(self.d.p(spec), verify=False)
+ resp.body = resp.content
+ return resp
def pathoc(
self,