mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 18:18:25 +00:00
Since we have locks over the logs, use direct access rather than API requests to get to them
This commit is contained in:
parent
40156ce123
commit
254614e9f7
@ -75,16 +75,13 @@ class Daemon:
|
||||
"""
|
||||
Return the log buffer as a list of dictionaries.
|
||||
"""
|
||||
resp = requests.get("%s/api/log" % self.urlbase, verify=False)
|
||||
return resp.json()["log"]
|
||||
return self.thread.server.get_log()
|
||||
|
||||
def clear_log(self):
|
||||
"""
|
||||
Clear the log.
|
||||
"""
|
||||
self.logfp.truncate(0)
|
||||
resp = requests.get("%s/api/clear_log" % self.urlbase, verify=False)
|
||||
return resp.ok
|
||||
return self.thread.server.clear_log()
|
||||
|
||||
def shutdown(self):
|
||||
"""
|
||||
@ -101,6 +98,7 @@ class _PaThread(threading.Thread):
|
||||
self.name = "PathodThread"
|
||||
self.iface, self.q, self.ssl = iface, q, ssl
|
||||
self.daemonargs = daemonargs
|
||||
self.server = None
|
||||
|
||||
def run(self):
|
||||
self.server = pathod.Pathod(
|
||||
|
@ -27,7 +27,7 @@ class TestApp(tutils.DaemonTests):
|
||||
def test_log(self):
|
||||
assert self.getpath("/log").status_code == 200
|
||||
assert self.get("200:da").status_code == 200
|
||||
id = self.d.log()[0]["id"]
|
||||
id = self.d.expect_log(1)[0]["id"]
|
||||
assert self.getpath("/log").status_code == 200
|
||||
assert self.getpath("/log/%s" % id).status_code == 200
|
||||
assert self.getpath("/log/9999999").status_code == 404
|
||||
|
@ -142,11 +142,10 @@ class CommonTests(tutils.DaemonTests):
|
||||
assert tuple(self.d.info()["version"]) == version.IVERSION
|
||||
|
||||
def test_logs(self):
|
||||
assert self.d.clear_log()
|
||||
assert not self.d.last_log()
|
||||
self.d.clear_log()
|
||||
assert self.get("202:da")
|
||||
assert len(self.d.log()) == 1
|
||||
assert self.d.clear_log()
|
||||
assert self.d.expect_log(1)
|
||||
self.d.clear_log()
|
||||
assert len(self.d.log()) == 0
|
||||
|
||||
def test_disconnect(self):
|
||||
|
Loading…
Reference in New Issue
Block a user