mirror of
https://github.com/ading2210/libcurl.js.git
synced 2025-05-13 14:30:02 -04:00
fix handling of request objects when passed into libcurl.fetch
This commit is contained in:
parent
c05ca1769e
commit
294fbd65f3
4 changed files with 13 additions and 3 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue