From 84174c465dcf8b7592aab02e200e8a924c238ea1 Mon Sep 17 00:00:00 2001 From: Joakim Bajoul Kakaei Date: Mon, 27 Oct 2025 09:53:09 +0000 Subject: [PATCH] fix: make chunked responses set the content-length if body is mutated As it stands now, the Broker sometiems rewrites the body. When it does, we don't also set the content-length to match the body. This can be potentially problematic. --- lib/hybrid-sdk/responseSenders.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/hybrid-sdk/responseSenders.ts b/lib/hybrid-sdk/responseSenders.ts index d9a78b754..720168e7f 100644 --- a/lib/hybrid-sdk/responseSenders.ts +++ b/lib/hybrid-sdk/responseSenders.ts @@ -86,6 +86,7 @@ export class HybridResponseHandler { if (this.config.RES_BODY_URL_SUB && isJson(response.headers)) { const replaced = replaceUrlPartialChunk(response.body, null, this.config); response.body = replaced.newChunk; + response.headers['content-length'] = response.body.length; } const status = (response && response.statusCode) || 500; logResponse(logContext, status, response, this.config);