aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2015-04-12 03:47:58 +0200
committerMaximilian Hils <git@maximilianhils.com>2015-04-12 03:47:58 +0200
commitc0a318566ae0fb5a264bfaa130f3ff3a09ea5bf5 (patch)
tree276583c71b7bb0425bad1953ebae4a7cc9c34a5f /examples
parent923503260ed48510da63e4dd1d6b36b4b859b110 (diff)
downloadmitmproxy-c0a318566ae0fb5a264bfaa130f3ff3a09ea5bf5.tar.gz
mitmproxy-c0a318566ae0fb5a264bfaa130f3ff3a09ea5bf5.tar.bz2
mitmproxy-c0a318566ae0fb5a264bfaa130f3ff3a09ea5bf5.zip
add flowwriter example
Diffstat (limited to 'examples')
-rw-r--r--examples/flowwriter.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/examples/flowwriter.py b/examples/flowwriter.py
new file mode 100644
index 00000000..2c253fbb
--- /dev/null
+++ b/examples/flowwriter.py
@@ -0,0 +1,17 @@
+from libmproxy.flow import FlowWriter
+import random
+import sys
+
+def start(context, argv):
+ if len(argv) != 2:
+ raise ValueError('Usage: -s "flowriter.py filename"')
+
+ if argv[1] == "-":
+ f = sys.stdout
+ else:
+ f = open(argv[1], "wb")
+ context.flow_writer = FlowWriter(f)
+
+def response(context, flow):
+ if random.choice([True, False]):
+ context.flow_writer.add(flow) \ No newline at end of file