fix(kernel): body size calculation in web relay (#5141)

Co-authored-by: CuriousCorrelation <CuriousCorrelation@gmail.com>
This commit is contained in:
Soumya Makkar 2025-06-19 12:32:07 +05:30 committed by GitHub
parent 8a88016d00
commit a1079ee61a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -222,6 +222,11 @@ export const implementation: VersionedAPI<RelayV1> = {
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<RelayV1> = {
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,
},
},
}