]> git.feebdaed.xyz Git - 0xmirror/mitmproxy.git/commitdiff
fix: add flush to buffered file handle (#7967)
authorCaíque Porfirio <56317416+caiquejjx@users.noreply.github.com>
Mon, 10 Nov 2025 00:50:09 +0000 (21:50 -0300)
committerGitHub <noreply@github.com>
Mon, 10 Nov 2025 00:50:09 +0000 (00:50 +0000)
* fix: add flush to buffered file handle

* chore: add changelog entry

* [autofix.ci] apply automated fixes

* fix: remove flush in favor of disabling buffering

* fix: properly remove flush call

* fix: add flush call into writer

* Update mitmproxy/addons/save.py

Co-authored-by: Sujal Singh <email.sujalsingh@gmail.com>
* Update CHANGELOG.md

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Maximilian Hils <git@maximilianhils.com>
Co-authored-by: Sujal Singh <email.sujalsingh@gmail.com>
CHANGELOG.md
mitmproxy/io/io.py

index 71df2eea285f15ebe296e86346d89db660447be4..f1a95788239c45ae4d4caf05187ab60be6b4f26a 100644 (file)
@@ -7,6 +7,8 @@
 
 ## Unreleased: mitmproxy next
 
+- Flush flow file after each flow to allow further processing.
+  ([#7967](https://github.com/mitmproxy/mitmproxy/pull/7967), @caiquejjx)
 - infer_content_encoding: Fallback to UTF-8 for more content types
   ([#7961](https://github.com/mitmproxy/mitmproxy/pull/7961), @xu-cheng)
 - Remove `bless` from hex editors to avoid issues with macOS
index 579bd9e96bdf7875fe698d0d4c85429260d9311c..af89577d9a9b15a81b7fa0657f1697f64a288ec8 100644 (file)
@@ -82,7 +82,7 @@ class FlowReader:
 
 
 class FilteredFlowWriter:
-    def __init__(self, fo, flt):
+    def __init__(self, fo: BinaryIO, flt: flowfilter.TFilter | None):
         self.fo = fo
         self.flt = flt
 
@@ -91,6 +91,7 @@ class FilteredFlowWriter:
             return
         d = f.get_state()
         tnetstring.dump(d, self.fo)
+        self.fo.flush()
 
 
 def read_flows_from_paths(paths) -> list[flow.Flow]: