From 967d48bdfa8cd24f885d55d46407ccc9a83294a1 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Mon, 7 Aug 2017 01:46:04 +0200 Subject: [PATCH] [sans-io] remove hook replies Hooks should not have immediate replies. Instead, they should modify the object passed over the hook. --- mitmproxy/addons/proxyserver.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mitmproxy/addons/proxyserver.py b/mitmproxy/addons/proxyserver.py index 83b0e5867..5ec61be97 100644 --- a/mitmproxy/addons/proxyserver.py +++ b/mitmproxy/addons/proxyserver.py @@ -33,8 +33,9 @@ class ProxyConnectionHandler(server.ConnectionHandler): submit = lambda x: self.loop.call_soon_threadsafe(lambda: q.put_nowait(x)) hook.data.reply = AsyncReply(submit, hook.data) self.event_queue.put((hook.name, hook.data)) - reply = await q.get() - self.server_event(events.HookReply(hook, reply)) + await q.get() + if hook.blocking: + self.server_event(events.HookReply(hook, None)) def _debug(self, *args): x = log.LogEntry(" ".join(str(x) for x in args), "warn")