fix handling of request objects when passed into libcurl.fetch

This commit is contained in:
ading2210 2024-03-27 00:49:02 -04:00
parent c05ca1769e
commit 294fbd65f3
4 changed files with 13 additions and 3 deletions

View file

@ -1,5 +1,8 @@
# Libcurl.js Changelog:
## v0.6.7 (3/26/24):
- Fix handling of `Request` objects when passed into `libcurl.fetch`
## v0.6.6 (3/20/24):
- Fix random segfaults due to an improper invocation of libcurl

View file

@ -82,7 +82,14 @@ class HTTPSession extends CurlSession {
});
}
async fetch(url, params={}) {
async fetch(resource, params={}) {
let url = resource;
if (resource instanceof Request) {
url = resource.url;
params.body = params.body || await resource.blob();
params.headers = params.headers || Object.fromEntries(resource.headers);
params.method = params.method || resource.method;
}
let body = await this.constructor.create_options(params);
return await this.request_async(url, params, body);
}

View file

@ -1,6 +1,6 @@
{
"name": "libcurl.js",
"version": "0.6.6",
"version": "0.6.7",
"description": "An experimental port of libcurl to WebAssembly for use in the browser.",
"main": "libcurl.mjs",
"exports": {

@ -1 +1 @@
Subproject commit ae2ec5f867aa64495e99facfeecf4307ec46d702
Subproject commit 351682f7e19c8a7a58d261ba666abaae95f04f6a