Header menu logo fable-electron-docs-api

ProtocolResponse Type

Constructors

Constructor Description

ProtocolResponse(?error, ?statusCode, ?charset, ?mimeType, ?headers, ?data, ?path, ?url, ?referrer, ?method, ?session, ?uploadData)

Full Usage: ProtocolResponse(?error, ?statusCode, ?charset, ?mimeType, ?headers, ?data, ?path, ?url, ?referrer, ?method, ?session, ?uploadData)

Parameters:
    ?error : int - When assigned, the request will fail with the error number . For the available error numbers you can use, please see the net error list.
    ?statusCode : float - The HTTP response code, default is 200.
    ?charset : string - The charset of response body, default is "utf-8".
    ?mimeType : string - The MIME type of response body, default is "text/html". Setting mimeType would implicitly set the content-type header in response, but if content-type is already set in headers, the mimeType would be ignored.
    ?headers : Record<string, U2<string, string[]>> - An object containing the response headers. The keys must be string, and values must be either string or Array of string.
    ?data : U3<Buffer, string, Readable<obj>> - The response body. When returning stream as response, this is a Node.js readable stream representing the response body. When returning Buffer as response, this is a Buffer. When returning string as response, this is a string. This is ignored for other types of responses.
    ?path : string - Path to the file which would be sent as response body. This is only used for file responses.
    ?url : string - Download the url and pipe the result as response body. This is only used for URL responses.
    ?referrer : string - The referrer URL. This is only used for file and URL responses.
    ?method : string - The HTTP method. This is only used for file and URL responses.
    ?session : Session - The session used for requesting URL. The HTTP request will reuse the current session by default.
    ?uploadData : ProtocolResponseUploadData - The data used as upload data. This is only used for URL responses when method is "POST".

Returns: ProtocolResponse
?error : int

When assigned, the request will fail with the error number . For the available error numbers you can use, please see the net error list.

?statusCode : float

The HTTP response code, default is 200.

?charset : string

The charset of response body, default is "utf-8".

?mimeType : string

The MIME type of response body, default is "text/html". Setting mimeType would implicitly set the content-type header in response, but if content-type is already set in headers, the mimeType would be ignored.

?headers : Record<string, U2<string, string[]>>

An object containing the response headers. The keys must be string, and values must be either string or Array of string.

?data : U3<Buffer, string, Readable<obj>>

The response body. When returning stream as response, this is a Node.js readable stream representing the response body. When returning Buffer as response, this is a Buffer. When returning string as response, this is a string. This is ignored for other types of responses.

?path : string

Path to the file which would be sent as response body. This is only used for file responses.

?url : string

Download the url and pipe the result as response body. This is only used for URL responses.

?referrer : string

The referrer URL. This is only used for file and URL responses.

?method : string

The HTTP method. This is only used for file and URL responses.

?session : Session

The session used for requesting URL. The HTTP request will reuse the current session by default.

?uploadData : ProtocolResponseUploadData

The data used as upload data. This is only used for URL responses when method is "POST".

Returns: ProtocolResponse

Instance members

Instance member Description

this.charset

Full Usage: this.charset

The charset of response body, default is "utf-8".

this.data

Full Usage: this.data

The response body. When returning stream as response, this is a Node.js readable stream representing the response body. When returning Buffer as response, this is a Buffer. When returning string as response, this is a string. This is ignored for other types of responses.

this.error

Full Usage: this.error

When assigned, the request will fail with the error number . For the available error numbers you can use, please see the net error list.

this.headers

Full Usage: this.headers

An object containing the response headers. The keys must be string, and values must be either string or Array of string.

this.method

Full Usage: this.method

The HTTP method. This is only used for file and URL responses.

this.mimeType

Full Usage: this.mimeType

The MIME type of response body, default is "text/html". Setting mimeType would implicitly set the content-type header in response, but if content-type is already set in headers, the mimeType would be ignored.

this.path

Full Usage: this.path

Path to the file which would be sent as response body. This is only used for file responses.

this.referrer

Full Usage: this.referrer

The referrer URL. This is only used for file and URL responses.

this.session

Full Usage: this.session

The session used for requesting URL. The HTTP request will reuse the current session by default.

this.statusCode

Full Usage: this.statusCode

The HTTP response code, default is 200.

this.uploadData

Full Usage: this.uploadData

The data used as upload data. This is only used for URL responses when method is "POST".

this.url

Full Usage: this.url

Download the url and pipe the result as response body. This is only used for URL responses.

Type something to start searching.