As usual, found my error.
The following is properly matcing the regex :
local escUri = function (m)
local _str = "href=\\"http://10.0.9.44/?_redir_="
_str = _str .. ngx.escape_uri(m[1]) .. "\\""
return _str
end
local newStr, n, err = ngx.re.gsub(ngx.arg[1], "href=\\"(.*)\\"", escUri, "ijox")
print(ngx.arg[1]) --> still original text
From my debug logs, I can see that the regex susbstitution is happening properly. But the href still remains the same. Probably because of chunked data.
I will try to aggregate the response body and then do the substitution. But if someone sees anything wrong, your help would be appreciated.
-Vamshi