Purpose

The Request object contains all information related to the HTTP request made to an application. The request instance is sent on to the site after the rules are evaluated.

Some fields and methods for the Response object are not available in scripts used with an agent. See the Field Summary and Method Summary tables below for more information.

Groovy sample

//Retrieve the request object from the exchange object
def request = exc?.request
def contentType = request?.header?.getContentType()
def containsJson = contentType?.matchesBaseType("application/json")
//Check to make sure the request body contains JSON
if (!containsJson) {
fail()
} else {
    pass()
}

Field summary

Field Description

String uri

Returns the PingAccess URI that received the request.

void setUri(String)

Sets the PingAccess URI.

Method summary

Method Description

Method getMethod

Contains the HTTP method information from the request sent to the application.

Header getHeader

Contains the HTTP header information from the request sent to the application.

Warning:

Previously executed custom rules can modify these values.

Body getBody

Contains the HTTP body information from the request sent to the application. This field is not available in scripts used with an agent.
Warning:

Previously executed custom rules can modify these values.

Map<String, String[]> getQueryStringParams()

Parses and returns the query string parameters from the request. If the query string parameters cannot be parsed due to formatting errors, this method will throw a URISyntaxException. Groovy scripts that use this method are not required to catch this exception. Scripts that choose not to catch this exception will fail if the query string parameters are invalid.

Map<String, String[]> getPostParams()

Parse the form parameters from the body content of the request, assuming the content is encoded using the encoding defined by the application/x-www-form-urlencoded content type.

void setBodyContent(byte[] content)

Replaces the body content of the request. This method will also adjust the Content-Length header field to align with the length of the specified content.