Skip to content

Commit b4cd142

Browse files
committed
fix(mcp): drop stale framing headers on a capped response body
The wrapped body is the already-decoded stream, so content-encoding/content-length would misdescribe it — strip them, matching bufferUnderDeadline.
1 parent ec4472c commit b4cd142

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

apps/sim/lib/mcp/pinned-fetch.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,15 @@ function capResponseBody(response: Response, maxBytes: number): Response {
7070
},
7171
})
7272
)
73+
const headers = new Headers(response.headers)
74+
// The wrapped body is the already-decoded stream; drop framing headers that would
75+
// misdescribe it (consistent with `bufferUnderDeadline`).
76+
headers.delete('content-encoding')
77+
headers.delete('content-length')
7378
const wrapped = new Response(limited, {
7479
status: response.status,
7580
statusText: response.statusText,
76-
headers: response.headers,
81+
headers,
7782
})
7883
// `new Response()` resets `url`/`redirected` (empty/false); the SDK resolves relative
7984
// auth-metadata URLs (e.g. `resource_metadata`) against `response.url`, so carry them over.

0 commit comments

Comments
 (0)