fix(http): response with status code 204 (#960)

* Fix response construction with status code 204

* run pnpm build
This commit is contained in:
ppbl
2024-02-21 04:20:46 +02:00
committed by GitHub
parent 8645a02aee
commit 3f81555fbf
2 changed files with 19 additions and 9 deletions
+18 -8
View File
@@ -155,15 +155,25 @@ export async function fetch(
rid,
});
const body = await invoke<number[]>("plugin:http|fetch_read_body", {
rid: responseRid,
});
const body = await invoke<ArrayBuffer | number[]>(
"plugin:http|fetch_read_body",
{
rid: responseRid,
},
);
const res = new Response(new Uint8Array(body), {
headers,
status,
statusText,
});
const res = new Response(
body instanceof ArrayBuffer && body.byteLength
? body
: body instanceof Array && body.length
? new Uint8Array(body)
: null,
{
headers,
status,
statusText,
},
);
// url is read only but seems like we can do this
Object.defineProperty(res, "url", { value: url });