JSHttpResponse


The HttpResponse is a subclass of JSHttpMessage, and inherits all the properties and methods of its base class. In addition, the HttpResponse has the following properties:

Properties

cookies

An array of JSResCookie objects. The array may be referenced by name (returns the value of the first cookie with that name), or by index (returns a JSResCookie object). A new cookie can be created by assigning a string to a nonexistent name. This property may also be read or written as a string, in which case it returns the contents of the Set-Cookie headers.

code

The response code.

codeMsg

The response explanation message.

protocol

The response protocol (e.g. HTTP/1.1)

Example

// Set the cookie named CookieName to have
// value CookieValue (create it if does not exist)
res.cookies["CookieName"] = "CookieValue;
domain=www.sanctuminc.com; secure";
// Set the first cookie to have name CookieName, value CookieValue
// and path /
req.cookies[0] = "CookieName=CookieValue; path=/";

if (res.cookies.length > 0) {
// Print the expiration time of the first cookie
alert("The name of the first cookie is " + res.cookies[0].expires);
}