Synthetic Classic has reached end of support and is no longer available. Existing Synthetic Classic customers have been upgraded to the all-in-one Dynatrace software intelligence platform.

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); }"