Commit 73973af
fix(egress): unblock SSE/chunked streaming through mitmproxy (#898)
* fix(egress): unblock SSE/chunked streaming through mitmproxy
The mitmdump --set stream_large_bodies=1m option (added to prevent OOM
on large downloads) buffers any response under 1 MiB before forwarding,
which stalls LLM SSE / chunked streams of small chunks until the stream
ends or the threshold is hit, producing perceptible stutter downstream.
Introduce a bundled system addon that is always loaded by the egress
launcher and forces flow.response.stream = True for responses with
content-type: text/event-stream or transfer-encoding: chunked. Large-
body OOM protection from stream_large_bodies stays intact for everything
else.
The previous example script add_header.py is renamed to system.py and
repurposed as the always-on system addon (wire-transparent: no headers
added or altered). User-supplied addons via OPENSANDBOX_EGRESS_MITMPROXY_SCRIPT
are still loaded after the system addon and may observe or override its
hooks.
Refs: https://project.aone.alibaba-inc.com/v2/project/2135082/req/82131871
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(egress): case-insensitive header match and correct system addon docs
Normalize content-type and transfer-encoding to lowercase before substring
matching in the system addon, so legal mixed-case values like
Transfer-Encoding: Chunked or Content-Type: Text/Event-Stream still trigger
streaming instead of getting buffered by stream_large_bodies=1m.
Also fix the transparent-mode doc, which referenced a non-existent
OPENSANDBOX_EGRESS_MITMPROXY_SYSTEM_SCRIPT env var as a way to disable or
swap the system addon. The launcher always appends the bundled system addon
unconditionally; document that users override behavior via
OPENSANDBOX_EGRESS_MITMPROXY_SCRIPT (loaded after the system addon).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>1 parent e0a7346 commit 73973af
4 files changed
Lines changed: 61 additions & 22 deletions
File tree
- components/egress
- docs
- mitmscripts
- pkg/mitmproxy
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | | - | |
| 33 | + | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
66 | 74 | | |
67 | 75 | | |
68 | 76 | | |
69 | | - | |
| 77 | + | |
70 | 78 | | |
71 | 79 | | |
72 | | - | |
| 80 | + | |
73 | 81 | | |
74 | | - | |
| 82 | + | |
75 | 83 | | |
76 | 84 | | |
77 | 85 | | |
78 | 86 | | |
79 | 87 | | |
80 | 88 | | |
81 | | - | |
| 89 | + | |
82 | 90 | | |
83 | 91 | | |
84 | 92 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
37 | 41 | | |
38 | 42 | | |
39 | 43 | | |
40 | 44 | | |
41 | 45 | | |
| 46 | + | |
42 | 47 | | |
43 | 48 | | |
44 | 49 | | |
| |||
120 | 125 | | |
121 | 126 | | |
122 | 127 | | |
123 | | - | |
124 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
125 | 132 | | |
126 | 133 | | |
127 | 134 | | |
| |||
0 commit comments