Module ringo/webapp/util
Functions
- getMimeParameter(headerValue, paramName)
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.add (name, value)
Add a header with the given name and value.
Parameters
| name | the header name | |
| value | the header value |
Headers.prototype.contains (name)
Queries whether a header with the given name is set
Parameters
| name | the header name |
Returns
| Boolean | true if a header with this name is set |
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 |
Headers.prototype.toString ()
Returns a string representation of the headers in MIME format.
Returns
| String | a string representation of the headers |
Headers.prototype.unset (name)
Unsets any cookies with the given name
Parameters
| name | the header name |
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 |
