Request interface

A JavaScript object implementing the Request interface represents an HTTP request.

Construction

Constructed by the Platform when a plugin handles a request, available through the request property of the Exchange object.

Interface

property method

HTTP method. "GET" or "POST".

property path

The requested URL path.

For example, "/do/example/object".

property extraPathElements

An array of path elements below the root URL of the handler.

For example, ["123y7","view"] for a request of /do/example/object/123y7/view.

property parameters

The parameters from the GET url and the POST body. POST parameters take precedence.

Both the keys and values are String values.

If a key name contains [], it is used to build a nested structure. For example,

    id=123&user[name]=John&user[address][city]=London&user[address][postcode]=SE1%201AA

would result in the structure

{
    id: "123",
    user: {
        name: "John",
        address: {
            city: "London",
            postcode: "SE1 1AA"
        }
    }
}

property headers

The HTTP request headers, as an Object with properties named after the headers, normalised so that each word is capitalised (eg User-Agent). The values are arrays containing the header values as strings. These arrays are never empty.

Arrays are used instead of simple strings because HTTP allows for repeated headers.

property remote

Information about the remote host making the request.

The object has two properties, protocol which is a string value giving the protocol name, for example, "IPv4", and address, which is the address of the remote host converted to a string.

If you are using the remote address for access control, make sure you check the protocol as well as the address, and deny access if the protocol isn’t one you expect.

For example, within a request handler:

Property path Value
E.request.remote.protocol "IPv4"
E.request.remote.address "10.1.2.3"

property body

The raw request body, interpreted as a UTF-8 string.