aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2016-05-28 13:21:07 +1200
committerAldo Cortesi <aldo@nullcube.com>2016-05-28 13:21:07 +1200
commit00426534982ab7fba5617ad6422c13483a8e6521 (patch)
treef97ad56816f4cf9f31093726be5bcf0960d50421
parent735bbe52e10f2f11275942db0ded8cb681f4b60d (diff)
downloadmitmproxy-00426534982ab7fba5617ad6422c13483a8e6521.tar.gz
mitmproxy-00426534982ab7fba5617ad6422c13483a8e6521.tar.bz2
mitmproxy-00426534982ab7fba5617ad6422c13483a8e6521.zip
Be stricter about the handler call signature
Uses this to catch an error in mitmweb
-rw-r--r--mitmproxy/controller.py8
-rw-r--r--mitmproxy/web/__init__.py1
2 files changed, 7 insertions, 2 deletions
diff --git a/mitmproxy/controller.py b/mitmproxy/controller.py
index 57c01f59..ac7c6cbc 100644
--- a/mitmproxy/controller.py
+++ b/mitmproxy/controller.py
@@ -161,7 +161,13 @@ NO_REPLY = object()
def handler(f):
@functools.wraps(f)
def wrapper(*args, **kwargs):
- message = args[-1]
+ if len(args) == 1:
+ message = args[0]
+ elif len(args) == 2:
+ message = args[1]
+ else:
+ raise ControlError("Handler takes one argument: a message")
+
if not hasattr(message, "reply"):
raise ControlError("Message %s has no reply attribute"%message)
diff --git a/mitmproxy/web/__init__.py b/mitmproxy/web/__init__.py
index d90830d6..7fef6df1 100644
--- a/mitmproxy/web/__init__.py
+++ b/mitmproxy/web/__init__.py
@@ -211,7 +211,6 @@ class WebMaster(flow.FlowMaster):
super(WebMaster, self).handle_error(f)
self._process_flow(f)
- @controller.handler
def add_event(self, e, level="info"):
super(WebMaster, self).add_event(e, level)
self.state.add_event(e, level)