aboutsummaryrefslogtreecommitdiffstats
path: root/examples/simple/io_write_dumpfile.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/simple/io_write_dumpfile.py')
-rw-r--r--examples/simple/io_write_dumpfile.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/examples/simple/io_write_dumpfile.py b/examples/simple/io_write_dumpfile.py
index 311950af..cf7c4f52 100644
--- a/examples/simple/io_write_dumpfile.py
+++ b/examples/simple/io_write_dumpfile.py
@@ -7,23 +7,21 @@ to multiple files in parallel.
"""
import random
import sys
-from mitmproxy import io
+from mitmproxy import io, http
+import typing # noqa
class Writer:
- def __init__(self, path):
+ def __init__(self, path: str) -> None:
if path == "-":
- f = sys.stdout
+ f = sys.stdout # type: typing.IO[typing.Any]
else:
f = open(path, "wb")
self.w = io.FlowWriter(f)
- def response(self, flow):
+ def response(self, flow: http.HTTPFlow) -> None:
if random.choice([True, False]):
self.w.add(flow)
-def start(opts):
- if len(sys.argv) != 2:
- raise ValueError('Usage: -s "flowriter.py filename"')
- return Writer(sys.argv[1])
+addons = [Writer(sys.argv[1])]