@caido/quickjs-types / caido/http
caido/http
Classes
Blob
A Blob encapsulates immutable, raw data.
Extended by
Constructors
new Blob()
new Blob(
parts: (string|ArrayBuffer|Blob)[],opts?:BlobOpts):Blob
Creates a new Blob object containing a concatenation of the given sources.
{ArrayBuffer}, and {Blob} sources are copied into the 'Blob' and can therefore be safely modified after the 'Blob' is created.
String sources are also copied into the Blob.
Parameters
| Parameter | Type |
|---|---|
parts | (string | ArrayBuffer | Blob)[] |
opts? | BlobOpts |
Returns
Properties
size
readonlysize:number
The total size of the Blob in bytes.
type
readonlytype:string
The content-type of the Blob.
Methods
arrayBuffer()
arrayBuffer():
Promise<ArrayBuffer>
Returns a promise that fulfills with an ArrayBuffer containing a copy of the Blob data.
Returns
Promise<ArrayBuffer>
bytes()
bytes():
Promise<Uint8Array>
Returns a promise that resolves with an Uint8Array containing the contents of the Blob.
Returns
Promise<Uint8Array>
slice()
slice(
start?:number,end?:number,type?:string):Blob
Creates and returns a new Blob containing a subset of this Blob objects data. The original Blob is not altered.
Parameters
| Parameter | Type | Description |
|---|---|---|
start? | number | The starting index. |
end? | number | The ending index. |
type? | string | The content-type for the new Blob |
Returns
text()
text():
Promise<string>
Returns a promise that fulfills with the contents of the Blob decoded as a UTF-8 string.
Returns
Promise<string>
File
A Blob encapsulates immutable, raw data.
Extends
Constructors
new File()
new File(
data: (string|ArrayBuffer|Blob)[],fileName:string,opts?:FileOpts):File
Returns a newly constructed File.
Parameters
| Parameter | Type |
|---|---|
data | (string | ArrayBuffer | Blob)[] |
fileName | string |
opts? | FileOpts |
Returns
Overrides
Properties
lastModified
readonlylastModified:number
The last modified date of the file as the number of milliseconds since the Unix epoch (January 1, 1970 at midnight). Files without a known last modified date return the current date.
name
readonlyname:string
Name of the file referenced by the File object.
size
readonlysize:number
The total size of the Blob in bytes.
Inherited from
type
readonlytype:string
The content-type of the Blob.
Inherited from
Methods
arrayBuffer()
arrayBuffer():
Promise<ArrayBuffer>
Returns a promise that fulfills with an ArrayBuffer containing a copy of the Blob data.
Returns
Promise<ArrayBuffer>
Inherited from
bytes()
bytes():
Promise<Uint8Array>
Returns a promise that resolves with an Uint8Array containing the contents of the Blob.
Returns
Promise<Uint8Array>
Inherited from
slice()
slice(
start?:number,end?:number,type?:string):Blob
Creates and returns a new Blob containing a subset of this Blob objects data. The original Blob is not altered.
Parameters
| Parameter | Type | Description |
|---|---|---|
start? | number | The starting index. |
end? | number | The ending index. |
type? | string | The content-type for the new Blob |
Returns
Inherited from
text()
text():
Promise<string>
Returns a promise that fulfills with the contents of the Blob decoded as a UTF-8 string.
Returns
Promise<string>
Inherited from
Headers
Implements
Iterable<[string,string]>
Constructors
new Headers()
new Headers(
opts?:HeadersOpts):Headers
Creates a new Headers object.
Parameters
| Parameter | Type |
|---|---|
opts? | HeadersOpts |
Returns
Properties
[iterator]()
readonly[iterator]: () =>Iterator<[string,string]>
Returns
Iterator<[string, string]>
Implementation of
Iterable.[iterator]
append()
readonlyappend: (name:string,value:string) =>void
Appends a new value onto an existing header inside a Headers object, or adds the header if it does not already exist.
Parameters
| Parameter | Type |
|---|---|
name | string |
value | string |
Returns
void
delete()
readonlydelete: (name:string) =>void
Deletes a header from a Headers object.
Parameters
| Parameter | Type |
|---|---|
name | string |
Returns
void
entries()
readonlyentries: () =>IterableIterator<[string,string]>
Returns an iterator allowing to go through all key/value pairs contained in this object.
Returns
IterableIterator<[string, string]>
forEach()
readonlyforEach: (callbackfn: (value:string,key:string) =>void) =>void
Executes a provided function once for each key/value pair in this Headers object.
Parameters
| Parameter | Type |
|---|---|
callbackfn | (value: string, key: string) => void |
Returns
void
get()
readonlyget: (name:string) =>null|string
A String sequence representing the values of the retrieved header or null if this header is not set.
Parameters
| Parameter | Type |
|---|---|
name | string |
Returns
null | string
getSetCookie()
readonlygetSetCookie: () =>string[]
Returns an array containing the values of all Set-Cookie headers associated with a response.
Returns
string[]
has()
readonlyhas: (name:string) =>boolean
Returns a boolean stating whether a Headers object contains a certain header.
Parameters
| Parameter | Type |
|---|---|
name | string |
Returns
boolean
keys()
readonlykeys: () =>IterableIterator<string>
Returns an iterator allowing you to go through all keys of the key/value pairs contained in this object.
Returns
IterableIterator<string>
set()
readonlyset: (name:string,value:string) =>void
Sets a new value for an existing header inside a Headers object, or adds the header if it does not already exist.
Parameters
| Parameter | Type |
|---|---|
name | string |
value | string |
Returns
void
values()
readonlyvalues: () =>IterableIterator<string>
Returns an iterator allowing you to go through all values of the key/value pairs contained in this object.
Returns
IterableIterator<string>
Request
The Request interface of the Fetch API represents a resource request.
Constructors
new Request()
new Request(
input:string|Request,init?:RequestOpts):Request
Creates a new Request object.
Parameters
| Parameter | Type |
|---|---|
input | string | Request |
init? | RequestOpts |
Returns
Properties
arrayBuffer()
readonlyarrayBuffer: () =>Promise<ArrayBuffer>
Returns a promise that resolves with an ArrayBuffer representation of the request body.
Returns
Promise<ArrayBuffer>
blob()
readonlyblob: () =>Promise<Blob>
Returns a promise that resolves with a Blob representation of the request body.
Returns
Promise<Blob>
body
readonlybody:Body
The body content.
bodyUsed
readonlybodyUsed:boolean
Stores true or false to indicate whether or not the body has been used in a request yet.
bytes()
readonlybytes: () =>Promise<Uint8Array>
Returns a promise that resolves with a Uint8Array representation of the request body.
Returns
Promise<Uint8Array>
cache
readonlycache:"no-cache"
Contains the cache mode of the request
clone()
readonlyclone: () =>Request
Creates a copy of the current Request object.
Returns
headers
readonlyheaders:Headers
Contains the associated Headers object of the request.
json()
readonlyjson: () =>Promise<unknown>
Returns a promise that resolves with the result of parsing the request body as JSON.
Returns
Promise<unknown>
keepalive
readonlykeepalive:boolean
Contains the request's keepalive setting (true or false), which indicates whether llrt will keep the associated connection alive.
method
readonlymethod:string
Contains the request's method (GET, POST, etc.)
mode
readonlymode:"navigate"
Contains the mode of the request
signal
readonlysignal:AbortSignal
Returns the AbortSignal associated with the request
text()
readonlytext: () =>Promise<string>
Returns a promise that resolves with a text representation of the request body.
Returns
Promise<string>
url
readonlyurl:string
Contains the URL of the request.
Response
The Response interface of the Fetch API represents the response to a request.
Constructors
new Response()
new Response(
body?:Body,opts?:ResponseOpts):Response
Creates a new Response object.
Parameters
| Parameter | Type |
|---|---|
body? | Body |
opts? | ResponseOpts |
Returns
Properties
arrayBuffer()
readonlyarrayBuffer: () =>Promise<ArrayBuffer>
Returns a promise that resolves with an ArrayBuffer representation of the response body.
Returns
Promise<ArrayBuffer>
blob()
readonlyblob: () =>Promise<Blob>
Returns a promise that resolves with a Blob representation of the response body.
Returns
Promise<Blob>
body
readonlybody:null
The body content (NOT IMPLEMENTED YET).
bodyUsed
readonlybodyUsed:boolean
Stores a boolean value that declares whether the body has been used in a response yet.
clone()
readonlyclone: () =>Response
Creates a clone of a Response object.
Returns
headers
readonlyheaders:Headers
The Headers object associated with the response.
json()
readonlyjson: () =>Promise<unknown>
Returns a promise that resolves with the result of parsing the response body text as JSON.
Returns
Promise<unknown>
ok
readonlyok:boolean
A boolean indicating whether the response was successful (status in the range 200 – 299) or not.
redirected
readonlyredirected:boolean
Indicates whether or not the response is the result of a redirect (that is, its URL list has more than one entry).
status
readonlystatus:number
The status code of the response. (This will be 200 for a success).
statusText
readonlystatusText:string
The status message corresponding to the status code. (e.g., OK for 200).
text()
readonlytext: () =>Promise<string>
Returns a promise that resolves with a text representation of the response body.
Returns
Promise<string>
type
readonlytype:ResponseType
The type of the response.
url
readonlyurl:string
Methods
error()
staticerror():Response
Returns a new Response object associated with a network error.
Returns
json()
staticjson(data:any,init?:ResponseInit):Response
Returns a new Response object for returning the provided JSON encoded data.
Parameters
| Parameter | Type |
|---|---|
data | any |
init? | ResponseInit |
Returns
redirect()
staticredirect(url:string,status?:number):Response
Returns a new Response with a different URL.
Parameters
| Parameter | Type |
|---|---|
url | string |
status? | number |
Returns
Interfaces
BlobOpts
Extended by
Properties
endings?
optionalendings:"transparent"|"native"
One of either 'transparent' or 'native'. When set to 'native', line endings in string source parts will be converted to the platform native line-ending as specified by import { EOL } from 'os'.
type?
optionaltype:string
The Blob content-type. The intent is for type to convey the MIME media type of the data, however no validation of the type format is performed.
FileOpts
Extends
Properties
endings?
optionalendings:"transparent"|"native"
One of either 'transparent' or 'native'. When set to 'native', line endings in string source parts will be converted to the platform native line-ending as specified by import { EOL } from 'os'.
Inherited from
lastModified?
optionallastModified:number
The last modified date of the file as the number of milliseconds since the Unix epoch (January 1, 1970 at midnight). Files without a known last modified date return the current date.
type?
optionaltype:string
The Blob content-type. The intent is for type to convey the MIME media type of the data, however no validation of the type format is performed.
Inherited from
RequestOpts
Properties
body?
optionalbody:Blob
headers?
optionalheaders:HeadersLike
method?
optionalmethod:string
signal?
optionalsignal:AbortSignal
url?
optionalurl:string
ResponseInit
Extended by
Properties
headers?
readonlyoptionalheaders:HeadersLike
status?
readonlyoptionalstatus:number
statusText?
readonlyoptionalstatusText:string
ResponseOpts
Extends
Properties
headers?
readonlyoptionalheaders:HeadersLike
Inherited from
signal?
readonlyoptionalsignal:AbortSignal
status?
readonlyoptionalstatus:number
Inherited from
statusText?
readonlyoptionalstatusText:string
Inherited from
url?
readonlyoptionalurl:string
Type Aliases
Body
Body:
ArrayBufferView|Blob|null
The Body of a Response or Request. Currently NOT a ReadableStream.
HeadersLike
HeadersLike:
Record<string,string> |Headers
HeadersOpts
HeadersOpts:
string[][] |HeadersLike
RequestCache
RequestCache:
"no-cache"
RequestMode
RequestMode:
"navigate"
ResponseType
ResponseType:
"basic"|"error"
Functions
fetch()
fetch(
input:string|Request,init?:RequestOpts):Promise<Response>
Parameters
| Parameter | Type |
|---|---|
input | string | Request |
init? | RequestOpts |
Returns
Promise<Response>
