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 (L166)

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 (L132)

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


.removeAllHeaders(key)
headerset
Source (L200)

Removes all headers matching a given key name.

Parameters

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

Return Value

`undefined`

Example

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

Back to top


.removeHeader(key)
headerset
Source (L183)

Removes the last matching header.

Parameters

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

Return Value

`undefined`

Example

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

Back to top


Last updated Tue Nov 15 2016 22:28:30 GMT+0000 (UTC)