aboutsummaryrefslogtreecommitdiffstats
path: root/examples/simple/io_read_dumpfile.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/simple/io_read_dumpfile.py')
-rw-r--r--examples/simple/io_read_dumpfile.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/examples/simple/io_read_dumpfile.py b/examples/simple/io_read_dumpfile.py
new file mode 100644
index 00000000..edbbe2dd
--- /dev/null
+++ b/examples/simple/io_read_dumpfile.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+#
+# Simple script showing how to read a mitmproxy dump file
+#
+
+from mitmproxy import io
+from mitmproxy.exceptions import FlowReadException
+import pprint
+import sys
+
+with open(sys.argv[1], "rb") as logfile:
+ freader = io.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 FlowReadException as e:
+ print("Flow file corrupted: {}".format(e))