NOTE: You are viewing documentation for the MoovJS/Adapt version of the Moovweb SDK
View documentation for next-gen Moovweb XDN & PWA framework
Moovweb | headers Namespace
Menu Developer Moovweb University

headers Namespace

Header manipulation getters, setters, and methods to be used from within moov_request_header_transform.js (for upstream request headers) or moov_response_header_transform.js (for transformed response headers).


.method
headerset
Source (L54)

Gets or sets the request method (request only).
Example
headers.method = 'POST';
// => Result: Moovweb goes upstream with a POST request method.
headers.method;
// => Returns: 'POST'

.path
headerset
Source (L68)

Gets or sets the request URL (request only).
Example
headers.path = '/test-page';
// => Result: Moovweb goes upstream requesting the /test-page URL, even if
//    the user requested another page. headers.path;
// => Returns: '/test-page'

.statusCode
headerset
Source (L96)

Gets or sets the status code (response only).
Example
headers.statusCode = '600';
// => Result: Moovweb modifies the response to return a 600 status code.
headers.statusCode;
// => Returns: '600'

.statusText
headerset
Source (L110)

Gets or sets the status text (response only).
Example
headers.statusText = 'Test Message';
// => Result: Moovweb modifies the response to return a 'Test Message' status
//    text.
headers.statusText;
// => Returns: 'Test Message'

.versionMinor
headerset
Source (L82)

Gets or sets the HTTP minor version.
Example
headers.versionMinor = '0';
// => Result: Moovweb modifies the request or response to use HTTP/1.0.
headers.versionMinor;
// => Returns: '0'

.addHeader(key, val)
headerset
Source (L170)

Adds a new header.

Parameters

Name Type Description
key String A string for the header key.
val String A string for the header value.

Return Value

`undefined`

Example

headers.addHeader('X-New-Header-Key', 'New Header Value');
// => Result: New 'X-New-Header-Key' key-value pair.

Back to top


.header(key, [val])
headerset
Source (L136)

Accesses the value for the given header. If a second `val` argument is supplied, then this adds a new header key-value pair, or modifies it if it already exists.

Parameters

Name Type Description
key String A string for the header key.
[ val ] String Optional. A string for the header value.

Return Value

A string for the header value (getter), or `undefined` (setter).

Examples

headers.header('User-Agent');
// => Returns: A string for the User-Agent header value.
headers.addHeader('X-New-Header-Key', 'New Header Value');
// => Result: New 'X-New-Header-Key' key-value pair.
headers.header('User-Agent', env.user_agent + '/Moovweb');
// => Result: Updated User-Agent header.

Back to top


.headerKeys()
headerset
Source (L187)

Returns an array of header keys of all set headers.

Return Value

An array of header keys of all set headers.

Example

headers.addHeader("X-New-Header-Key", "New Header Value");
headers.headerKeys();
// => Returns: An array of keys that includes "X-New-Header-Key".

Back to top


.removeAllHeaders(key)
headerset
Source (L301)

Removes all headers matching a given key name.

Parameters

Name Type Description
key String A string for the header key to remove.

Return Value

array of header values removed.

Example

headers.removeAllHeaders('Set-Cookie');
// => Result: Removes all Set-Cookie headers.

Back to top


.removeCookie(key)
headerset
Source (L202)

Removes all Cookie headers matching the parameter.

Parameters

Name Type Description
key String The name of the Cookie to remove.

Return Value

Array of cookie values removed.

Example

headers.removeCookie('device_type');
// => Result: Removes all Cookie headers for cookies name 'device_type'

Back to top


.removeHeader(key)
headerset
Source (L278)

Removes the last matching header.

Parameters

Name Type Description
key String A string for the header key to remove.

Return Value

value of header removed.

Example

headers.removeHeader('Set-Cookie');
// => Result: Removes the last found Set-Cookie header.

Back to top


.removeSetCookie(key)
headerset
Source (L248)

Removes all SetCookie headers matching the parameter.

Parameters

Name Type Description
key String The name of the SetCookie to remove.

Return Value

Array of cookie values removed.

Example

headers.removeSetCookie('device_type');
// => Result: Removes all SetCookie headers for cookies name 'device_type'

Back to top


Last updated Mon Feb 26 2018 22:51:29 GMT+0000 (UTC)