Documentation

HDRequest

Object containing information about the request. An instance of this object is created automatically, and is available in the request variable.

Object Properties & Methods

 cookieA method to return the value of a client-side cookie.
 formThe form fields submitted by the client.
 headersThe HTTP headers submitted in the request.
 methodThe HTTP method used by the request.
 parsedURLA parsed version of the URL used to submit the request.
 sessionA reference to the user's session.
 urlThe URL used to submit the request.
 userdataAn object you can use to hold data during the processing of the request.

cookie

MethodFirst available in version 1.0.0

The cookie(name) method returns the value of a named client-side cookie. (Cookies can be set using the setCookie(name, value) method of the HDResponse object.)

Usage:

request.cookie(name);

Arguments:

nameThe name of the cookie to return. (string)

Returns: the cookie value, or null if the named cookie was not previously set.

Example:

// Get the value of the cookie with the name "theCookieName"
var cookieValue = request.cookie("theCookieName");

form

PropertyFirst available in version 1.0.0

A JavaScript object containing the form fields submitted by the client in the request. The keys of the array are determined by the name property of each form object, or by the object's id if the name property is omitted.

Example:

// Determine the value of the "field1" form field
var value = request.form["field1"];

headers

PropertyFirst available in version 1.0.0

A JavaScript object containing the HTTP headers submitted in the request. All of the header names have been converted to lower-case.

Example:

// Get the user-agent request header
var userAgent = request.headers["user-agent"];

method

PropertyFirst available in version 1.0.0

The HTTP method used by the request. Typically either "GET" or "POST".

Example:

// Determine the request was made with the GET method
if(request.method == "GET")
{
	console.log("Request used the GET method.");
}

parsedURL

PropertyFirst available in version 1.0.0

An JavaScript object containing a parsed version of the URL used to submit the request.

For example, for the URL "/page1.hdml?field1=value", the array will contain the following items:

hrefThe full URL ("/page1.hdml?field1=value")
searchThe information following the path ("?field1=value")
queryThe parsed query parameters, as a JavaScript object ({ field1: "value"})
pathnameThe pathname portion of the URL ("/page1.hdml")

Example:

// Return the value of the "field1" query parameter:
var field1 = request.parsedURL.query["field1"];

session

PropertyFirst available in version 1.0.0

A reference to an HDSession object representing the user's session.

Example:

// Store a value from a form field in a user session
var value = request.form["field1"];
request.session.set("theValue", value);

url

PropertyFirst available in version 1.0.0

The URL used to submit the request. This will typically be composed of the path and any query parameters present in the URL. (For a version that's been parsed into its component pieces, see the parsedURL property.)

Example:

// log the request URL:
console.log(request.url);

userdata

PropertyFirst available in version 1.0.0

An object you can use to hold data during the processing of the request. For example, you can store data calculated in an onGET handler for use when processing embedded scripting.

Example:

request.userdata["someValue"] = "a string";

Then, in the content of an client-side HDDiv object:

## This is a header
The value calculated in the onGET handler: <%= request.userdata["someValue"] %> 

Copyright © 2010-2017, Handheld Designer, LLC, All Rights Reserved.
Made by hand in New England, USA.