Generating a complete response
This scenario illustrates how to generate a complete HTTP response.
Script
-- IBM Confidential
-- PID 5725-V89 5725-V90 5737-F02
--
-- Copyright IBM Corp. 2022, 2022
-- This script is used to test the creation of a custom HTTP response.
url = HTTPRequest.getURL()
-- Only send our custom response if the URL contains the string:
-- 'custom.response'
if string.find(url, "custom.response") then
HTTPResponse.setHeader("content-type", "text/html")
HTTPResponse.setCookie("my-cookie", "cookie-value; Secure; HttpOnly")
HTTPResponse.setBody("<html><body><h1>This is an example transformation response!</h1></body></html>")
HTTPResponse.setStatusCode(200)
HTTPResponse.setStatusMsg("OK")
Control.responseGenerated(true)
end