Access the Response object in Groovy exc?.response
.
Purpose
The Response object contains all information related to the service HTTP response. The response instance is sent on to the User-Agent after the rules are evaluated.
The fields and methods for the Response object are not available in scripts used with an agent.
Groovy sample
if(exc?.response && exc?.identity) {
exc.response.header.add("PA-Tracking-ID", exc.identity.trackingId)
}
pass()
Field summary
Field | Description |
---|---|
int getStatusCode() | Contains the HTTP response status code. |
void setStatusCode(int) | Sets the status code from an integer. |
String getStatusMessage() | Contains the HTTP response status message. |
void setStatusMessage(String) | Sets the status message from a string. |
Method summary
Method | Description |
---|---|
boolean isRedirect() | Returns true if the status code is in the 300s. |
Header getHeader | Contains the HTTP
header information from the response. Warning:
Previously executed custom rules can modify these values. |
Body getBody | Contains the HTTP body
information from the response. Warning:
Previously executed custom rules can modify these values. |
void setBodyContent(byte[] content) | Replaces the body content of the response. This method will also adjust the Content-Length header field to align with the length of the specified content. |