Request object reference
Access the Request object in Groovy exc?.request
.
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.
Refer to the Field summary and Method summary tables 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 |
---|---|
|
Returns the PingAccess Uniform Resource Identifier (URI) that received the request. |
|
Sets the PingAccess URI. |
Method summary
Method | Description | ||
---|---|---|---|
Method |
Contains the HTTP method information from the request sent to the application. |
||
Header |
Contains the HTTP header information from the request sent to the application.
|
||
Body |
Contains the HTTP body information from the request sent to the application. This field is not available in scripts used with an agent.
|
||
|
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. |
||
|
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. |
||
|
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. |