fix(common): pre-process proxy response to base type (#4910)

This commit is contained in:
Shreyas 2025-03-19 13:12:32 +05:30 committed by GitHub
parent a64c72e8fb
commit 2b5395011a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -340,13 +340,13 @@ export class ProxyKernelInterceptorService
// NOTE: This should be conditional but seems to be hit always,
// see std/interceptor/proxy.ts for more info. Also see the above similar note.
if (parsedProxyResponse.isBinary) {
const decodedData = decodeB64StringToArrayBuffer(
parsedProxyResponse.data
const decodedData = new Uint8Array(
decodeB64StringToArrayBuffer(parsedProxyResponse.data)
)
// NOTE: This is also for backwards compat,
// better solution would be to ask for raw bytes from proxyscotch.
const jsonResult = parseBytesToJSON(new Uint8Array(decodedData))
const jsonResult = parseBytesToJSON(decodedData)
if (O.isSome(jsonResult)) {
return E.right({
@ -382,7 +382,7 @@ export class ProxyKernelInterceptorService
statusText: parsedProxyResponse.statusText,
headers: parsedProxyResponse.headers,
body: {
body: parsedProxyResponse.data,
body: new TextEncoder().encode(parsedProxyResponse.data),
mediaType:
parsedProxyResponse.headers["content-type"] || "text/plain",
},