MCPcopy Index your code
hub / github.com/mitmproxy/mitmproxy / export_har

Method export_har

mitmproxy/addons/savehar.py:36–47  ·  view source on GitHub ↗

Export flows to an HAR (HTTP Archive) file.

(self, flows: Sequence[flow.Flow], path: types.Path)

Source from the content-addressed store, hash-verified

34
35 @command.command("save.har")
36 def export_har(self, flows: Sequence[flow.Flow], path: types.Path) -> None:
37 """Export flows to an HAR (HTTP Archive) file."""
38
39 har = json.dumps(self.make_har(flows), indent=4).encode()
40
41 if path.endswith(".zhar"):
42 har = zlib.compress(har, 9)
43
44 with open(path, "wb") as f:
45 f.write(har)
46
47 logging.log(ALERT, f"HAR file saved ({human.pretty_size(len(har))} bytes).")
48
49 def make_har(self, flows: Sequence[flow.Flow]) -> dict:
50 entries = []

Callers 4

test_write_errorFunction · 0.95
test_saveharFunction · 0.95
doneMethod · 0.95
test_savehar.pyFile · 0.80

Calls 5

make_harMethod · 0.95
dumpsMethod · 0.80
encodeMethod · 0.45
writeMethod · 0.45
logMethod · 0.45

Tested by 2

test_write_errorFunction · 0.76
test_saveharFunction · 0.76