mitmproxy/examples/flowwriter.py
Aldo Cortesi b94f5fd361 Convert examples and example tests for new-style scripts
Remove the test that just loads all the example scripts for now - it's a very
low-value test, and we need to think of something better.
2016-07-14 19:54:15 +12:00

23 lines
427 B
Python

import random
import sys
from mitmproxy.flow import FlowWriter
state = {}
def configure(options):
if len(sys.argv) != 2:
raise ValueError('Usage: -s "flowriter.py filename"')
if sys.argv[1] == "-":
f = sys.stdout
else:
f = open(sys.argv[1], "wb")
state["flow_writer"] = FlowWriter(f)
def response(flow):
if random.choice([True, False]):
state["flow_writer"].add(flow)