aboutsummaryrefslogtreecommitdiffstats
path: root/examples/read_dumpfile.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2014-02-04 19:10:55 +0100
committerMaximilian Hils <git@maximilianhils.com>2014-02-04 19:10:55 +0100
commit6d9b28f2ea07d61a856cf6fddf0bbe0b61e0bdb2 (patch)
tree02c741fb5ceef5f20a463d65137da1dcdaaf66ba /examples/read_dumpfile.py
parentfd828bf95981780f5cce300e389c18ca43bfddce (diff)
downloadmitmproxy-6d9b28f2ea07d61a856cf6fddf0bbe0b61e0bdb2.tar.gz
mitmproxy-6d9b28f2ea07d61a856cf6fddf0bbe0b61e0bdb2.tar.bz2
mitmproxy-6d9b28f2ea07d61a856cf6fddf0bbe0b61e0bdb2.zip
add example to show how to read mitmproxy dump files, refs #207
Diffstat (limited to 'examples/read_dumpfile.py')
-rw-r--r--examples/read_dumpfile.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/examples/read_dumpfile.py b/examples/read_dumpfile.py
new file mode 100644
index 00000000..547f3c17
--- /dev/null
+++ b/examples/read_dumpfile.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+#
+# Simple script showing how to read a mitmproxy dump file
+#
+
+from libmproxy import flow
+import json, sys
+
+with open("logfile", "rb") as f:
+ freader = flow.FlowReader(f)
+ try:
+ for i in freader.stream():
+ print i.request.host
+ json.dump(i._get_state(), sys.stdout, indent=4)
+ print ""
+ except flow.FlowReadError, v:
+ print "Flow file corrupted. Stopped loading." \ No newline at end of file