GLOBAL INDEX  |  FRAMES  |  NO FRAMES
Library: response
Overview
Helpers for the HTTP response.
source: response.js
Functions
response.forbid()
Halts the program immediately and returns 403 Forbidden error to the user.
response.stop(renderCurrentPage)
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.
response.notFound()
Halts the program immediately and returns a 404 not found error to the user.
response.redirect(path)
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
response.setStatusCode(newCode)
Sets the status code in the HTTP response.
parameters
number newCode
response.setHeader(name, value)
Sets any header of the HTTP response.
parameters
string name
string value
examples
response.setHeader('Cache-Control', 'no-cache');
response.addHeader(name, value)
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
response.write(data)
Low-level hook for writing raw data to the response.
parameters
string data will be written, verbatim, to the HTTP resonse.
response.setCookie(cookieObject)
Set a cookie in the response.
parameters
object cookieObject This may contain any of the following:
  • name (required): The name of the cookie
  • value (required): The value of the cookie. (Note: this value will be escaped).
  • expires (optional): If an integer, means number of days until it expires; if a Date object, means exact date on which to expire.
  • domain (optional): The cookie domain
  • path (optional): To restrict the cookie to a specific path.
  • secure (optional): Whether this cookie should only be sent securely.
examples
response.setCookie({
  name: "SessionID",
  value: "25",
  secure: true,
  expires: 14 // 14 days
});
response.deleteCookie(name)
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.
response.setContentType(contentType)
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
response.setCacheable(cacheable)
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
object
response
Generated by JsDoc Toolkit 1.3.3 on Thu, 03 Jul 2008 01:27:43 GMT.