JSMA header

Overview

What can JSMA header do for me?

The JSMA header allows you to read and write the header field in requests and responses.

Index

Methods

The JSMA header provides the following methods:

string header.get(key)

Returns the value of key as string or null if no value is set under the key.

Example

var acceptHeader = request.header.get("HTTP_ACCEPT");
var acceptsWebP = acceptHeader.indexOf("image/webp") > -1;

Parameter key:string (required)

The key to be looked up in the flexAttributes of the header

void header.set(key, value)

Sets the value of a specified key for the header

Example

if (autoOptimize) {
  response.header.set("Vary", "Accept-Encoding,Accept");
}

Parameter key:string (required)

The key to be set in the flexAttributes of the header.

Parameter value:string (required)

The value to be set for the key

string[] header.keys

Returns a list of keys from the headers.

Example

var headerKeys = header.keys;

if (headerKeys.length > 0) {  
  for (int i = 0; i < headerKeys.length; i++) {
	result.push(headerKeys[i]);
  }
}