2019-06-28 07:25:30 +00:00
|
|
|
# ProtocolResponse Object
|
|
|
|
|
|
|
|
* `error` Integer (optional) - When assigned, the `request` will fail with the
|
|
|
|
`error` number . For the available error numbers you can use, please see the
|
|
|
|
[net error list][net-error].
|
2021-11-16 04:13:18 +00:00
|
|
|
* `statusCode` number (optional) - The HTTP response code, default is 200.
|
|
|
|
* `charset` string (optional) - The charset of response body, default is
|
2019-06-28 07:25:30 +00:00
|
|
|
`"utf-8"`.
|
2021-11-16 04:13:18 +00:00
|
|
|
* `mimeType` string (optional) - The MIME type of response body, default is
|
2019-06-28 07:25:30 +00:00
|
|
|
`"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, string | string[]> (optional) - An object containing the response headers. The
|
2021-11-16 04:13:18 +00:00
|
|
|
keys must be string, and values must be either string or Array of string.
|
|
|
|
* `data` (Buffer | string | ReadableStream) (optional) - The response body. When
|
2019-06-28 07:25:30 +00:00
|
|
|
returning stream as response, this is a Node.js readable stream representing
|
|
|
|
the response body. When returning `Buffer` as response, this is a `Buffer`.
|
2021-11-16 04:13:18 +00:00
|
|
|
When returning `string` as response, this is a `string`. This is ignored for
|
2019-06-28 07:25:30 +00:00
|
|
|
other types of responses.
|
2021-11-16 04:13:18 +00:00
|
|
|
* `path` string (optional) - Path to the file which would be sent as response
|
2019-06-28 07:25:30 +00:00
|
|
|
body. This is only used for file responses.
|
2021-11-16 04:13:18 +00:00
|
|
|
* `url` string (optional) - Download the `url` and pipe the result as response
|
2019-06-28 07:25:30 +00:00
|
|
|
body. This is only used for URL responses.
|
2021-11-16 04:13:18 +00:00
|
|
|
* `referrer` string (optional) - The `referrer` URL. This is only used for file
|
2019-06-28 07:25:30 +00:00
|
|
|
and URL responses.
|
2021-11-16 04:13:18 +00:00
|
|
|
* `method` string (optional) - The HTTP `method`. This is only used for file
|
2019-06-28 07:25:30 +00:00
|
|
|
and URL responses.
|
|
|
|
* `session` Session (optional) - The session used for requesting URL, by default
|
|
|
|
the HTTP request will reuse the current session. Setting `session` to `null`
|
|
|
|
would use a random independent session. This is only used for URL responses.
|
2020-11-02 10:01:46 +00:00
|
|
|
* `uploadData` [ProtocolResponseUploadData](protocol-response-upload-data.md) (optional) - The data used as upload data. This is only
|
2019-06-28 07:25:30 +00:00
|
|
|
used for URL responses when `method` is `"POST"`.
|
|
|
|
|
2022-03-17 12:45:55 +00:00
|
|
|
[net-error]: https://source.chromium.org/chromium/chromium/src/+/main:net/base/net_error_list.h
|