From a1079ee61a17ba6a9245a3477653a1e4cb76ffa8 Mon Sep 17 00:00:00 2001 From: Soumya Makkar Date: Thu, 19 Jun 2025 12:32:07 +0530 Subject: [PATCH] fix(kernel): body size calculation in web relay (#5141) Co-authored-by: CuriousCorrelation --- .../hoppscotch-kernel/src/relay/impl/web/v/1.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/hoppscotch-kernel/src/relay/impl/web/v/1.ts b/packages/hoppscotch-kernel/src/relay/impl/web/v/1.ts index ce2417b5..f7244494 100644 --- a/packages/hoppscotch-kernel/src/relay/impl/web/v/1.ts +++ b/packages/hoppscotch-kernel/src/relay/impl/web/v/1.ts @@ -222,6 +222,11 @@ export const implementation: VersionedAPI = { normalizedHeaders["Content-Type"] || normalizedHeaders["CONTENT-TYPE"] + const rawBody = axiosResponse.data + const bodySize = rawBody.byteLength + + const headerSize = JSON.stringify(axiosResponse.headers).length + const response: RelayResponse = { id: request.id, status: axiosResponse.status, @@ -235,11 +240,9 @@ export const implementation: VersionedAPI = { end: endTime, }, size: { - headers: JSON.stringify(axiosResponse.headers).length, - body: axiosResponse.data?.length ?? 0, - total: - JSON.stringify(axiosResponse.headers).length + - (axiosResponse.data?.length ?? 0), + headers: headerSize, + body: bodySize, + total: headerSize + bodySize, }, }, }