Question

I need to set a custom header in Kamailio 3.3.1 from a Lua script. I can theoretically set one in the config script like this -

append_hf("X-MyHeader: myvalue\r\n");

but I cannot work out how to call it from a Lua script, which is my preferred place to do this from. I have the following in my CFG file -

modparam("app_lua", "load", "/usr/local/etc/kamailio/lua/kamailio.lua")
modparam("app_lua", "register", "sl")
modparam("app_lua", "register", "rr")
modparam("app_lua", "register", "tm")

and my Lua script works fine as far as it goes. Documentation seems to suggest that append_hf() is part of the textops module, but I can see no way to expose that to the Lua script.

Please can anyone help me understand this or maybe suggest an alternative way to achieve my goal?

Was it helpful?

Solution

Done it.

You need to use -

sr.hdr.append("header: value\r\n");

I've spent 2 days looking for that. And 5 mins after posting I find it. Here's the URL where i got the answer from -

http://www.kamailio.org/wiki/embeddedapi/3.2.x/lua

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top