Library: response
Overview
Helpers for the HTTP response.
source: response.js
Functions
Halts the program immediately, optionally printing the page so far.
parameters
| boolean | renderCurrentPage | if false, an empty page will be rendered, otherwise calls to print() so far will be displayed. Either way, no more code will be executed. |
Halts the program immediately and sends an HTTP redirect response (302),
redirecting to the given path (relative or absolute).
parameters
| string | path | The new path |
Sets the status code in the HTTP response.
parameters
| number | newCode |
Sets any header of the HTTP response.
parameters
| string | name | |
| string | value |
examples
response.setHeader('Cache-Control', 'no-cache');
Adds the name,value pair to the headers. Useful for headers that are
allowed to repeat, such as Set-Cookie.
parameters
| string | name | |
| string | value |
Low-level hook for writing raw data to the response.
parameters
| string | data | will be written, verbatim, to the HTTP resonse. |
Set a cookie in the response.
parameters
| object | cookieObject |
This may contain any of the following:
|
examples
response.setCookie({
name: "SessionID",
value: "25",
secure: true,
expires: 14 // 14 days
});
Tells the client to delete the cookie of the given name (by setting
its expiration time to zero).
parameters
| string | name | The name of the cookie to delete. |
Sets the Content-Type header of the response. If the content-type includes
a charset, that charset is used to send the response.
parameters
| string | contentType | the new content-type |
Tells the client to cache the page. By default, clients are told to
not never cache pages. (To send no caching-related headers at all, pass
undefined.)parameters
| boolean | cacheable |
Objects