aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy/dump.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2010-03-01 14:58:04 +1300
committerAldo Cortesi <aldo@nullcube.com>2010-03-01 14:58:04 +1300
commitba92d22e1d789c189f2007f8b933c520e2a593a9 (patch)
treed4838b2f122e4f0dba223fe6ea660a6ab20eee34 /libmproxy/dump.py
parent0188cf8a1a9abc3b03fb1cee91ed2aa1f20b1ebd (diff)
downloadmitmproxy-ba92d22e1d789c189f2007f8b933c520e2a593a9.tar.gz
mitmproxy-ba92d22e1d789c189f2007f8b933c520e2a593a9.tar.bz2
mitmproxy-ba92d22e1d789c189f2007f8b933c520e2a593a9.zip
Put DumpMaster in its own file.
It's going to become a more important part of the mitmproxy suite now.
Diffstat (limited to 'libmproxy/dump.py')
-rw-r--r--libmproxy/dump.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/libmproxy/dump.py b/libmproxy/dump.py
new file mode 100644
index 00000000..83238da4
--- /dev/null
+++ b/libmproxy/dump.py
@@ -0,0 +1,39 @@
+import sys
+import controller
+
+class DumpMaster(controller.Master):
+ """
+ A simple master that just dumps to screen.
+ """
+ def __init__(self, server, verbosity):
+ self.verbosity = verbosity
+ controller.Master.__init__(self, server)
+
+ def run(self):
+ try:
+ return controller.Master.run(self)
+ except KeyboardInterrupt:
+ self.shutdown()
+
+ def handle_response(self, msg):
+ if 0 < self.verbosity < 3:
+ print >> sys.stderr, ">>",
+ print >> sys.stderr, msg.request.short()
+ if self.verbosity == 1:
+ print >> sys.stderr, "<<",
+ print >> sys.stderr, msg.short()
+ elif self.verbosity == 2:
+ print >> sys.stderr, "<<"
+ for i in msg.assemble().splitlines():
+ print >> sys.stderr, "\t", i
+ print >> sys.stderr, "<<"
+ elif self.verbosity == 3:
+ print >> sys.stderr, ">>"
+ for i in msg.request.assemble().splitlines():
+ print >> sys.stderr, "\t", i
+ print >> sys.stderr, ">>"
+ print >> sys.stderr, "<<"
+ for i in msg.assemble().splitlines():
+ print >> sys.stderr, "\t", i
+ print >> sys.stderr, "<<"
+ msg.ack()