mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
Support .zhar compression
This commit is contained in:
parent
ac97e5efa1
commit
567cbe6cb9
@ -7,6 +7,7 @@ import pprint
|
||||
import json
|
||||
import sys
|
||||
import base64
|
||||
import zlib
|
||||
|
||||
from datetime import datetime
|
||||
import pytz
|
||||
@ -155,14 +156,16 @@ def done():
|
||||
|
||||
if dump_file == '-':
|
||||
mitmproxy.ctx.log(pprint.pformat(HAR))
|
||||
# TODO: .zhar compression
|
||||
else:
|
||||
json_dump = json.dumps(HAR, indent=2)
|
||||
|
||||
if dump_file.endswith('.zhar'):
|
||||
json_dump = zlib.compress(json_dump, 9)
|
||||
|
||||
with open(dump_file, "w") as f:
|
||||
f.write(json_dump)
|
||||
|
||||
mitmproxy.ctx.log("HAR log finished (wrote %s bytes to file)" % len(json_dump))
|
||||
mitmproxy.ctx.log("HAR dump finished (wrote %s bytes to file)" % len(json_dump))
|
||||
|
||||
|
||||
def format_datetime(dt):
|
||||
|
Loading…
Reference in New Issue
Block a user