MCPcopy
hub / github.com/mitmproxy/mitmproxy / save_flow

Method save_flow

mitmproxy/addons/save.py:104–120  ·  view source on GitHub ↗

Write the flow to the stream, but first check if we need to rotate to a new file.

(self, flow: flow.Flow)

Source from the content-addressed store, hash-verified

102 self.current_path = path
103
104 def save_flow(self, flow: flow.Flow) -> None:
105 """
106 Write the flow to the stream, but first check if we need to rotate to a new file.
107 """
108 if not self.stream:
109 return
110 try:
111 self.maybe_rotate_to_new_file()
112 self.stream.add(flow)
113 except OSError as e:
114 # If we somehow fail to write flows to a logfile, we really want to crash visibly
115 # instead of letting traffic through unrecorded.
116 # No normal logging here, that would not be triggered anymore.
117 sys.stderr.write(f"Error while writing to {self.current_path}: {e}")
118 sys.exit(1)
119 else:
120 self.active_flows.discard(flow)
121
122 def done(self) -> None:
123 if self.stream:

Callers 6

tcp_endMethod · 0.95
udp_endMethod · 0.95
websocket_endMethod · 0.95
responseMethod · 0.95
dns_responseMethod · 0.95
dns_errorMethod · 0.95

Calls 4

exitMethod · 0.80
addMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected