Fork me on GitHub

Module ringo/webapp/util

Functions

Class Headers

Instance Methods

Class ResponseFilter

Instance Methods


Headers (headers)

Returns an object for use as a HTTP header collection. The returned object provides methods for setting, getting, and deleting its properties in a case-insensitive and case-preserving way.

This function can be used as mixin for an existing JavaScript object or as a constructor.

Parameters

headers an existing JS object. If undefined, a new object is created

Headers.prototype.get (name)

Get the value of the header with the given name

Parameters

name the header name

Returns

the header value

Headers.prototype.set (name, value)

Set the header with the given name to the given value.

Parameters

name the header name
value the header value

ResponseFilter (body, filter)

A utility class for implementing JSGI response filters. Each part of the response is first passed to the filter function. If the filter function returns a value, that value is passed on to the JSGI response stream.

Parameters

body a JSGI response body
filter a filter function

ResponseFilter.prototype.forEach (fn)

forEach function called by the JSGI connector.

Parameters

fn the response handler callback function

getMimeParameter (headerValue, paramName)

Get a parameter from a MIME header value. For example, calling this function with "Content-Type: text/plain; charset=UTF-8" and "charset" will return "UTF-8".

Parameters

headerValue a header value
paramName a MIME parameter name