diff options
Diffstat (limited to 'examples/complex/har_dump.py')
-rw-r--r-- | examples/complex/har_dump.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/examples/complex/har_dump.py b/examples/complex/har_dump.py index 9e287a19..33a2f79f 100644 --- a/examples/complex/har_dump.py +++ b/examples/complex/har_dump.py @@ -1,5 +1,11 @@ """ This inline script can be used to dump flows as HAR files. + +example cmdline invocation: +mitmdump -s ./har_dump.py --set hardump=./dump.har + +filename endwith '.zhar' will be compressed: +mitmdump -s ./har_dump.py --set hardump=./dump.zhar """ @@ -20,11 +26,11 @@ from mitmproxy import ctx from mitmproxy.utils import strutils from mitmproxy.net.http import cookies -HAR = {} # type: typing.Dict +HAR: typing.Dict = {} # A list of server seen till now is maintained so we can avoid # using 'connect' time for entries that use an existing connection. -SERVERS_SEEN = set() # type: typing.Set[connections.ServerConnection] +SERVERS_SEEN: typing.Set[connections.ServerConnection] = set() def load(l): @@ -155,12 +161,12 @@ def done(): Called once on script shutdown, after any other events. """ if ctx.options.hardump: - json_dump = json.dumps(HAR, indent=2) # type: str + json_dump: str = json.dumps(HAR, indent=2) if ctx.options.hardump == '-': mitmproxy.ctx.log(json_dump) else: - raw = json_dump.encode() # type: bytes + raw: bytes = json_dump.encode() if ctx.options.hardump.endswith('.zhar'): raw = zlib.compress(raw, 9) |