aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy/examples/read_dumpfile
diff options
context:
space:
mode:
Diffstat (limited to 'mitmproxy/examples/read_dumpfile')
-rw-r--r--mitmproxy/examples/read_dumpfile20
1 files changed, 20 insertions, 0 deletions
diff --git a/mitmproxy/examples/read_dumpfile b/mitmproxy/examples/read_dumpfile
new file mode 100644
index 00000000..b329c0e1
--- /dev/null
+++ b/mitmproxy/examples/read_dumpfile
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+#
+# Simple script showing how to read a mitmproxy dump file
+#
+
+from libmproxy import flow
+import pprint
+import sys
+
+with open(sys.argv[1], "rb") as logfile:
+ freader = flow.FlowReader(logfile)
+ pp = pprint.PrettyPrinter(indent=4)
+ try:
+ for f in freader.stream():
+ print(f)
+ print(f.request.host)
+ pp.pprint(f.get_state())
+ print("")
+ except flow.FlowReadError as v:
+ print "Flow file corrupted. Stopped loading."