"quickjs:curl" (namespace)
The "quickjs:curl" module provides networking functions implemented with
libcurl, which is loaded dynamically at runtime.
}
(url: string): string;
(
url: string,
},
): {
status: number;
response: ArrayBuffer;
responseHeaders: string;
};
(
url: string,
},
): {
status: number;
response: string;
responseHeaders: string;
};
(
url: string,
},
): {
status: number;
response: string;
responseHeaders: string;
};
(
url: string,
},
): ArrayBuffer;
(
url: string,
},
): ArrayBuffer;
(
url: string,
},
): string;
(
url: string,
},
): string;
(
url: string,
},
): string;
(
url: string,
},
): string;
(
url: string,
):
| string
| ArrayBuffer
| {
status: number;
response: string | ArrayBuffer;
responseHeaders: string;
};
}
}
(
method: string,
url: string,
): {
status: number;
response: string;
responseHeaders: {
[name: string]: Array<string> | undefined;
};
};
(
method: string,
url: string,
},
): {
status: number;
response: ArrayBuffer;
responseHeaders: {
[name: string]: Array<string> | undefined;
};
};
(
method: string,
url: string,
},
): {
status: number;
response: string;
responseHeaders: {
[name: string]: Array<string> | undefined;
};
};
(
method: string,
url: string,
): {
status: number;
response: string | ArrayBuffer;
responseHeaders: {
[name: string]: Array<string> | undefined;
};
};
}
}
"quickjs:curl".UrlGetOptions (exported interface)
Options for urlGet.
}
UrlGetOptions.binary (boolean property)
When true, the response body is returned as an ArrayBuffer instead of a string. Defaults to false.
UrlGetOptions.full (boolean property)
When true, urlGet returns an object with response, responseHeaders,
and status properties instead of only the response body, and it
doesn't throw when the http status code is outside 200-299. Defaults to
false.
UrlGetOptions.headers (property)
Request headers to send, as an object whose keys are header names and whose values are header values. Numbers and bigints get converted to strings. An empty string sends the header with no value.
Be aware that libcurl may also add other headers, such as Accept or
Host. That said, the header values you specify will take precedence
over values added by libcurl.
"quickjs:curl".UrlGet (exported interface)
(url: string): string;
(
url: string,
},
): {
status: number;
response: ArrayBuffer;
responseHeaders: string;
};
(
url: string,
},
): {
status: number;
response: string;
responseHeaders: string;
};
(
url: string,
},
): {
status: number;
response: string;
responseHeaders: string;
};
(
url: string,
},
): ArrayBuffer;
(
url: string,
},
): ArrayBuffer;
(
url: string,
},
): string;
(
url: string,
},
): string;
(
url: string,
},
): string;
(
url: string,
},
): string;
(
url: string,
):
| string
| ArrayBuffer
| {
status: number;
response: string | ArrayBuffer;
responseHeaders: string;
};
}
UrlGet(...) (call signature)
Download url using libcurl (dynamically loaded). Returns string when
the http status code is between 200 and 299, and throws otherwise.
Pass an object with { full: true } as the second argument to get response headers and status code. See UrlGetOptions for all options.
(url: string): string;
UrlGet(...) (call signature)
Download url using libcurl (dynamically loaded).
Returns an object with three properties:
response: response body content (ArrayBuffer)responseHeaders: headers separated by CRLF (string)status: status code (number)
See UrlGetOptions for all options.
UrlGet(...) (call signature)
Download url using libcurl (dynamically loaded).
Returns an object with three properties:
response: response body content (string)responseHeaders: headers separated by CRLF (string)status: status code (number)
See UrlGetOptions for all options.
(url: string, options: UrlGetOptions & {
}): {
status: number;
response: string;
responseHeaders: string;
};
UrlGet(...) (call signature)
Download url using libcurl (dynamically loaded).
Returns an object with three properties:
response: response body content (string)responseHeaders: headers separated by CRLF (string)status: status code (number)
See UrlGetOptions for all options.
UrlGet(...) (call signature)
Download url using libcurl (dynamically loaded). Returns ArrayBuffer
when the http status code is between 200 and 299, and throws otherwise.
Pass an object with { full: true } as the second argument to get response headers and status code. See UrlGetOptions for all options.
(url: string, options: UrlGetOptions & {
}): ArrayBuffer;
UrlGet(...) (call signature)
Download url using libcurl (dynamically loaded). Returns ArrayBuffer
when the http status code is between 200 and 299, and throws otherwise.
Pass an object with { full: true } as the second argument to get response headers and status code. See UrlGetOptions for all options.
UrlGet(...) (call signature)
Download url using libcurl (dynamically loaded). Returns string when
the http status code is between 200 and 299, and throws otherwise.
Pass an object with { full: true } as the second argument to get response headers and status code. See UrlGetOptions for all options.
(url: string, options: UrlGetOptions & {
}): string;
UrlGet(...) (call signature)
Download url using libcurl (dynamically loaded). Returns string when
the http status code is between 200 and 299, and throws otherwise.
Pass an object with { full: true } as the second argument to get response headers and status code. See UrlGetOptions for all options.
(url: string, options: UrlGetOptions & {
}): string;
UrlGet(...) (call signature)
Download url using libcurl (dynamically loaded). Returns string when
the http status code is between 200 and 299, and throws otherwise.
Pass an object with { full: true } as the second argument to get response headers and status code. See UrlGetOptions for all options.
UrlGet(...) (call signature)
Download url using libcurl (dynamically loaded). Returns string when
the http status code is between 200 and 299, and throws otherwise.
Pass an object with { full: true } as the second argument to get response headers and status code. See UrlGetOptions for all options.
UrlGet(...) (call signature)
Download url using libcurl (dynamically loaded).
When the full option is true, returns an object with three
properties:
response: response body content (ArrayBuffer when thebinaryoption is true, string otherwise)responseHeaders: headers separated by CRLF (string)status: status code (number)
Otherwise, returns the response body (ArrayBuffer when the binary
option is true, string otherwise) when the http status code is between
200 and 299, and throws otherwise.
See UrlGetOptions for all options.
(url: string, options: UrlGetOptions): string | ArrayBuffer | {
status: number;
response: string | ArrayBuffer;
responseHeaders: string;
};
"quickjs:curl".urlGet (exported UrlGet)
"quickjs:curl".UrlRequestOptions (exported interface)
Options for urlRequest.
}
UrlRequestOptions.body (property)
The request body. Strings are sent as UTF-8.
When omitted, the request has no body, except that a POST request sends an empty one.
When a body is sent, libcurl adds the header
Content-Type: application/x-www-form-urlencoded, unless you specify a
Content-Type in headers.
Passing a body with the HEAD method throws a TypeError.
UrlRequestOptions.redirect (property)
What to do when the server responds with a redirect. Defaults to "follow".
"follow": Follow any 3xx response that has aLocationheader. See UrlRequest for how redirects affect the method and body."error": Throw an Error for any response that"follow"would follow, which is any 3xx response that has aLocationheader. A 3xx response without aLocationheader is returned as-is."manual": Don't follow the redirect.urlRequestreturns the redirect response itself, with its status, headers (includinglocation), and body.
"quickjs:curl".UrlRequest (exported interface)
The type of urlRequest.
By default, urlRequest follows redirects, which affect the request like
this:
- After a 301, 302, or 303 redirect, a POST becomes a GET without a body, like in browsers.
- A 303 redirect also drops the body of any other method, but keeps the method.
- Otherwise, the method and body are both kept.
Use the redirect option to throw on redirects or to get the redirect
response instead. See UrlRequestOptions.
(
method: string,
url: string,
): {
status: number;
response: string;
responseHeaders: {
[name: string]: Array<string> | undefined;
};
};
(
method: string,
url: string,
},
): {
status: number;
response: ArrayBuffer;
responseHeaders: {
[name: string]: Array<string> | undefined;
};
};
(
method: string,
url: string,
},
): {
status: number;
response: string;
responseHeaders: {
[name: string]: Array<string> | undefined;
};
};
(
method: string,
url: string,
): {
status: number;
response: string | ArrayBuffer;
responseHeaders: {
[name: string]: Array<string> | undefined;
};
};
}
UrlRequest(...) (call signature)
Send a request to url using libcurl (dynamically loaded).
Returns an object with three properties:
response: response body content (string)responseHeaders: an object whose keys are lowercased header names and whose values are arrays of header values (it's an array in case the header is specified more than once)status: status code (number)
Unlike urlGet, this doesn't throw when the http status code is
outside 200-299. Redirects are followed unless the redirect option
says otherwise; see UrlRequest for how they affect the method
and body.
@parammethod — The request method, such as"GET","POST","PUT", or"DELETE". It's sent exactly as written, so it's case-sensitive.@paramurl — The URL to send the request to.
(method: string, url: string): {
status: number;
response: string;
responseHeaders: {
[name: string]: Array<string> | undefined;
};
};
UrlRequest(...) (call signature)
Send a request to url using libcurl (dynamically loaded).
Returns an object with three properties:
response: response body content (ArrayBuffer)responseHeaders: an object whose keys are lowercased header names and whose values are arrays of header values (it's an array in case the header is specified more than once)status: status code (number)
Unlike urlGet, this doesn't throw when the http status code is
outside 200-299. Redirects are followed unless the redirect option
says otherwise; see UrlRequest for how they affect the method
and body.
@parammethod — The request method, such as"GET","POST","PUT", or"DELETE". It's sent exactly as written, so it's case-sensitive.@paramurl — The URL to send the request to.@paramoptions — Options pertaining to the request. See UrlRequestOptions for all options.
(method: string, url: string, options: UrlRequestOptions & {
}): {
status: number;
response: ArrayBuffer;
responseHeaders: {
[name: string]: Array<string> | undefined;
};
};
UrlRequest(...) (call signature)
Send a request to url using libcurl (dynamically loaded).
Returns an object with three properties:
response: response body content (string)responseHeaders: an object whose keys are lowercased header names and whose values are arrays of header values (it's an array in case the header is specified more than once)status: status code (number)
Unlike urlGet, this doesn't throw when the http status code is
outside 200-299. Redirects are followed unless the redirect option
says otherwise; see UrlRequest for how they affect the method
and body.
@parammethod — The request method, such as"GET","POST","PUT", or"DELETE". It's sent exactly as written, so it's case-sensitive.@paramurl — The URL to send the request to.@paramoptions — Options pertaining to the request. See UrlRequestOptions for all options.
(method: string, url: string, options: UrlRequestOptions & {
}): {
status: number;
response: string;
responseHeaders: {
[name: string]: Array<string> | undefined;
};
};
UrlRequest(...) (call signature)
Send a request to url using libcurl (dynamically loaded).
Returns an object with three properties:
response: response body content (ArrayBuffer when thebinaryoption is true, string otherwise)responseHeaders: an object whose keys are lowercased header names and whose values are arrays of header values (it's an array in case the header is specified more than once)status: status code (number)
Unlike urlGet, this doesn't throw when the http status code is
outside 200-299. Redirects are followed unless the redirect option
says otherwise; see UrlRequest for how they affect the method
and body.
@parammethod — The request method, such as"GET","POST","PUT", or"DELETE". It's sent exactly as written, so it's case-sensitive.@paramurl — The URL to send the request to.@paramoptions — Options pertaining to the request. See UrlRequestOptions for all options.
(method: string, url: string, options: UrlRequestOptions): {
status: number;
response: string | ArrayBuffer;
responseHeaders: {
[name: string]: Array<string> | undefined;
};
};
"quickjs:curl".urlRequest (exported UrlRequest)