Hi,
I am trying to intercept the response body of HTTP requests in a lua script using the register_fetches core API.
My lua code is as follows:
local function resp_filter(txn)
local payload = txn.f:req_body()
if payload ~= nil then
core.Info("** Response " .. payload .. "\n")
else
core.Info("** Response is nil")
end
end
core.register_fetches("resp_filter", resp_filter)
I am calling the function as follows from config file
http-response set-var(txn.req_body) lua.resp_filter
However I am getting the response body as nil for versions 1.9.7 - 2.1.12. It is working fine for versions outside of this bracket.
NOTE: The API was changed from req.body to res.body post version 2.2.
Why is the req.body returning nil for the versions mentioned above but is working fine prior to those releases?