rename content -> body
This commit is contained in:
parent
6d5a3da929
commit
11ac387df2
|
@ -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"]
|
||||
|
|
|
@ -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"]
|
||||
|
|
|
@ -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"]
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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"])
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue