Response Object
The response object represents the HTTP response and includes key:value pairs for the status and headers. Response headers can only be modified during the onClientResponse and onOriginResponseevents.
Properties
status
The status code of the HTTP response sent to the client.
📘 You can set the return value of the response.status field to a 2xx Success, 3xx Redirection, 4xx Client Error, or 5xx Server Error status code.
Methods
The following methods are available for the EdgeWorkers response objects.
addHeader()
Adds names and values to a header. If the header already exists, the name and value are appended.
Parameters
Review the table for information about the available parameters.
getHeader()
Returns an array of header values by header name. The header names are case insensitive. If the header doesn’t exist, a value of undefined is returned.
Parameters
Review the table for information about the available parameters.
getHeaders()
Returns a JavaScript object that contains all HTTP response headers as properties.
The key for each property is the name of the HTTP header, normalized to lower-case. The value is an array of strings, containing one string for each HTTP header with the same name.
removeHeader()
Removes the named header. The header name is case insensitive.
Parameters
Review the table for information about the available parameters.
setHeader()
Sets header values and replaces previous ones. Defines the new header name. The value can be a single string or an array.
Parameters
Review the table for information about the available parameters.