Commit 994159c
v0.14.2 apiproxy: rewrite streaming-request bodies too
The previous version bypassed the rewriter entirely when stream:true was
set on the request. But the request body is synchronous JSON regardless
of how the RESPONSE is delivered — only the response side is SSE-chunked.
So now: always rewrite the request body. For streaming responses, skip
the expand-loop interception (which would require parsing the full SSE
stream) and pass the response chunks straight through. Acceptable tradeoff:
the client may see the expand tool_use surface in rare cases, in exchange
for getting compression on the common Claude Code streaming case.
Live-session measurement on a real Claude Code Opus 4.7 turn:
/v1/messages received: 1,615,476 bytes
rewrote request: 946,994 bytes
saved: 668,482 bytes (1.70× / 41% reduction)
First time the proxy moved real bytes against real api.anthropic.com
traffic. Also added an always-on "request received" info log so the
diagnostic story is visible without code changes.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent e83b185 commit 994159c
1 file changed
Lines changed: 31 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
147 | 153 | | |
148 | 154 | | |
149 | 155 | | |
| |||
158 | 164 | | |
159 | 165 | | |
160 | 166 | | |
161 | | - | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
162 | 176 | | |
163 | 177 | | |
164 | 178 | | |
| |||
367 | 381 | | |
368 | 382 | | |
369 | 383 | | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
370 | 388 | | |
371 | 389 | | |
372 | 390 | | |
373 | 391 | | |
374 | 392 | | |
375 | 393 | | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
376 | 399 | | |
377 | 400 | | |
378 | 401 | | |
379 | | - | |
| 402 | + | |
| 403 | + | |
380 | 404 | | |
381 | 405 | | |
382 | 406 | | |
| |||
0 commit comments