fix bug with headers object and request objects passed into fetch

This commit is contained in:
ading2210 2024-09-11 13:31:57 -04:00
parent 754b211c59
commit 3c1a942501
2 changed files with 17 additions and 6 deletions

View file

@ -1,5 +1,13 @@
async function test() {
//regular fetch
let r = await libcurl.fetch("https://example.com/");
assert(r.status === 200, "wrong status");
await r.text();
//fetch with request object
let options = {headers: new Headers({"x-test-header": "1"})};
let r2 = await libcurl.fetch(new Request("https://httpbin.org/get", options));
assert(r2.status === 200, "wrong status");
let r2_json = await r2.json();
assert(r2_json.headers["X-Test-Header"] === "1");
}