Methods for the Response Object

The following methods are available for the EdgeWorkers response objects.

getHeader(name)

Returns an array of header values by header name. The header names are case insensitive. If the header doesn’t exist, an undefined array is returned..

Review the table for information about the possible arguments.

Argument Description Object Type
name Names of the headers in the array Array
// Content-Length: 100
response.getHeader('Content-Length')[0];
// => "100"

setHeader(name, value)

Sets header values and replaces previous ones. Define the new header name. The value can be a single string or an array.

Review the table for information about the possible arguments.

Argument Description Object Type
name Name of the header String
value Value of the header String or Array
// Powered-By: bar
response.setHeader('Powered-By','Akamai EdgeWorkers');
// Powered-By: Akamai EdgeWorkers 

addHeader(name, value)

Adds names and values to a header. If the header already exists, the name and value are appended. The value can be a single string or an array.

Review the table for information about the possible arguments.

Argument Description Object Type
name Names of the header String
value Value of the header String
//
response.addHeader('Powered-By','Akamai EdgeWorkers');
// Powered-By: Akamai EdgeWorkers
// Powered-By: Akamai EdgeWorkers
response.addHeader('Powered-By','Akamai ION');
// Powered-By: Akamai ION 
// Powered-By: Akamai EdgeWorkers

removeHeader(name)

Removes the named header. The header name is case insensitive.

Review the table for information about the possible arguments.

Argument Description Object Type
name Names of the header to remove String
// Debug: Debug Info
response.removeHeader('Debug');
//