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

Method save

mitmproxy/addons/save.py:133–151  ·  view source on GitHub ↗

Save flows to a file. If the path starts with a +, flows are appended to the file, otherwise it is over-written.

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

Source from the content-addressed store, hash-verified

131
132 @command.command("save.file")
133 def save(self, flows: Sequence[flow.Flow], path: mitmproxy.types.Path) -> None:
134 """
135 Save flows to a file. If the path starts with a +, flows are
136 appended to the file, otherwise it is over-written.
137 """
138 try:
139 with open(_path(path), _mode(path)) as f:
140 stream = io.FlowWriter(f)
141 for i in flows:
142 stream.add(i)
143 except OSError as e:
144 raise exceptions.CommandError(e) from e
145 if path.endswith(".har") or path.endswith(".zhar"): # pragma: no cover
146 logging.log(
147 ALERT,
148 f"Saved as mitmproxy dump file. To save HAR files, use the `save.har` command.",
149 )
150 else:
151 logging.log(ALERT, f"Saved {len(flows)} flows.")
152
153 def tcp_start(self, flow: tcp.TCPFlow):
154 if self.stream:

Callers 2

test_static_viewerFunction · 0.95
test_save_commandFunction · 0.95

Calls 4

addMethod · 0.95
_pathFunction · 0.85
_modeFunction · 0.85
logMethod · 0.45

Tested by 2

test_static_viewerFunction · 0.76
test_save_commandFunction · 0.76