Response()
The Response()
constructor creates a new Response
object.
Syntax
new Response()
new Response(body)
new Response(body, options)
Parameters
body
optional: An object defining a body for the response. This can be
null
(which is the default value), or one of:ArrayBuffer
TypedArray
DataView
ReadableStream
URLSearchParams
String
- string literal
options
optional: An options object containing any custom settings that you want to apply to the response, or an empty object (which is the default value). The possible options are:
status
- : The status code for the response, e.g.,
200
.
- : The status code for the response, e.g.,
statusText
- : The status message associated with the status code,
e.g.,
OK
.
- : The status message associated with the status code,
e.g.,
headers
manualFramingHeaders
: boolean optional Fastly-specific- : The default value is
false
, which means that the framing headers are automatically created based on the message body. In "automatic" mode, aContent-Length
is used when the size of the body can be determined before it is sent. Responses sent in streaming mode, where headers are sent immediately but the content of the body is streamed later, will receive aTransfer-Encoding: chunked
to accommodate the dynamic generation of the body. In "manual" mode, anyContent-Length
orTransfer-Encoding
headers will be honored. You must ensure that those headers have correct values permitted by the HTTP/1.1 specification. If the provided headers are not permitted by the specification, the headers will revert to "automatic" mode and a diagnostic message will be logged about what was wrong. If aContent-Length
is permitted by the specification, but the value does not match the size of the actual body, the body will either be truncated (if it is too long), or the connection will be hung up early (if it is too short).
- : The default value is