// Get the Message that immediately precedes this Script. var msg = $context.currentItem.previousItem; var header = msg.getResponse(msg.RESPONSE_HTTP_HEADER, "X-Core-Value"); $context.result.postMessage($context.result.LEVEL_INFO, "Cookie = "+ header); // Was there a header? if (header == null) { // There was no header. // Output an informational message. $context.result.postMessage($context.result.LEVEL_INFO, "No header to validate"); } else { // There was a response. // string to find; hard coded var stringToFind = "Family"; // Determine if the value exists in the header. var searchIndex = header.indexOf(stringToFind); // If the value does not exist in the header, output an error. if (searchIndex == -1) { var details = "Response:\n" + header + "\n\nValue searched for:\n" + stringToFind; $context.result.postMessage($context.result.LEVEL_ERROR, "Expected value not found in '" + msg.name + "' message header", details); } } msg.clearResponse();