parent
92a5076bd0
commit
917d51bd22
|
@ -2,7 +2,7 @@
|
|||
This inline script utilizes harparser.HAR from
|
||||
https://github.com/JustusW/harparser to generate a HAR log object.
|
||||
"""
|
||||
import mitmproxy
|
||||
import mitmproxy.ctx
|
||||
import six
|
||||
import sys
|
||||
import pytz
|
||||
|
@ -221,9 +221,11 @@ def done():
|
|||
if context.dump_file == '-':
|
||||
mitmproxy.ctx.log(pprint.pformat(json.loads(json_dump)))
|
||||
elif context.dump_file.endswith('.zhar'):
|
||||
file(context.dump_file, "w").write(compressed_json_dump)
|
||||
with open(context.dump_file, "wb") as f:
|
||||
f.write(compressed_json_dump)
|
||||
else:
|
||||
file(context.dump_file, "w").write(json_dump)
|
||||
with open(context.dump_file, "wb") as f:
|
||||
f.write(json_dump)
|
||||
mitmproxy.ctx.log(
|
||||
"HAR log finished with %s bytes (%s bytes compressed)" % (
|
||||
len(json_dump), len(compressed_json_dump)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import json
|
||||
|
||||
import six
|
||||
import sys
|
||||
import os.path
|
||||
from mitmproxy.flow import master
|
||||
|
@ -112,7 +113,7 @@ class TestScripts(mastertest.MasterTest):
|
|||
)
|
||||
|
||||
path = os.path.join(tdir, "file")
|
||||
m, sc = tscript("har_extractor.py", path)
|
||||
m, sc = tscript("har_extractor.py", six.moves.shlex_quote(path))
|
||||
f = tutils.tflow(
|
||||
req=netutils.treq(**times),
|
||||
resp=netutils.tresp(**times)
|
||||
|
@ -120,6 +121,6 @@ class TestScripts(mastertest.MasterTest):
|
|||
self.invoke(m, "response", f)
|
||||
m.addons.remove(sc)
|
||||
|
||||
fp = open(path, "rb")
|
||||
test_data = json.load(fp)
|
||||
with open(path, "rb") as f:
|
||||
test_data = json.load(f)
|
||||
assert len(test_data["log"]["pages"]) == 1
|
||||
|
|
Loading…
Reference in New Issue