Capture response headers from a request

This sample code is an event hook that looks for a specific request and captures the value of the Last-Modified header in the response. The code can be modified to capture any of the different response headers. In the sample, we are alerting the value of the header to the debug header; however, any other actions that might be needed can be done here as well.

The demo script grabs the Server header from the site being tested, and then uses a Custom action to validate that the header is what is expected.

The demo script is here: HeaderValidation.gsl.

var send = new AddEventHookCommand({
"eventType": "replyReceived",
"name": "getHeaders",
"handler":"if(response.getRequest().getUrl().indexOf('crl') != -1){ alert('in conditional'); header = response.getHeader('Last-Modified'); alert (header); }"