I am working on a project where I need to send back 302
reply. Everything seems to work, except I can't remove certain headers, i.e. From, Contact, etc. (I don't want to remove them completely, but rather substitute with my own version of it). I use KEMI
with Lua to do so:
KSR.hdr.remove("From")
As I mentioned, this does not work (while other functions from hdr
work fine in the same context, namely KSR.hdr.append_to_reply(...)
.
I decided to look at the Kamailio source code and found following lines of code in kemi.c
file:
int sr_kemi_hdr_remove(sip_msg_t *msg, str *hname)
{
...
anchor=del_lump(msg, hf->name.s - msg->buf, hf->len, 0);
if (anchor==0) {
LM_ERR("cannot remove hdr %.*s\n", hname->len, hname->s);
return -1;
}
}
return 1;
}
Looking at the last parameter that del_lump
takes, it is of type _hdr_types_t
which describes an enum
of different header types. Now, in particular to me, there were three headers I was working with:
- From (type 4)
- Contact (type 7)
- Other (type 0)
So my question is, why does that function is hardcoded to take only OTHER
headers, but not other ones, i.e. From
and Contact
? Is that to safeguard from breaking the SIP request (inadvertently removing required headers)?
And as a follow up question, is it even possible to remove From
and Contact
from reply messages?