[OpenSIPS-Users] Remove previously added header

Ben Newlin Ben.Newlin at genesys.com
Tue Jun 15 00:23:42 EST 2021


David,

There is a difference between sequential branches and parallel branches. Just because you only have one branch at a time, does not mean that you aren’t creating multiple branches, as you’ve seen from your working script.

This solution is almost the best way to do it, except that removing the header in the second branch route is not necessary. Message changes made in branch route only exist in that branch, see the note here [1]. So after the 302 reply the header will already be gone from the next branch.

[1] - https://opensips.org/docs/modules/3.2.x/sipmsgops.html#func_append_hf

Ben Newlin

From: Users <users-bounces at lists.opensips.org> on behalf of David Villasmil <david.villasmil.work at gmail.com>
Date: Monday, June 14, 2021 at 7:43 PM
To: OpenSIPS users mailling list <users at lists.opensips.org>
Subject: Re: [OpenSIPS-Users] Remove previously added header
Ok i stumbled on to your email from back 2009 asking just about the same thing (https://users.opensips.narkive.com/W78SWsO9/opensips-users-remove-hf-doesn-t-always-work<https://users.opensips.narkive.com/W78SWsO9/opensips-users-remove-hf-doesn-t-always-work>)

I ended up doing
t_on_branch("1")

# Add the header before sending it out the parameter server
branch_route[1] {
    append_hf("X-MyHeader: 1\r\n");
}

then when actually sending it out to the termination provider:

t_on_branch("2");

# Remove the header before seding it out to the termination
branch_route[2] {
    remove_hf("X-MyHeader");
}

That's working perfectly!

Is this right or is there a more efficient/easier way to do it?

Thanks!

Regards,

David Villasmil
email: david.villasmil.work at gmail.com<mailto:david.villasmil.work at gmail.com>
phone: +34669448337


On Tue, Jun 15, 2021 at 12:10 AM David Villasmil <david.villasmil.work at gmail.com<mailto:david.villasmil.work at gmail.com>> wrote:
Thanks Jeff,

That's not going to work for me, I don't want to add new branches.
What I'm doing is forwarding the call to a sip server that replies with a 302 and some extra headers.
I then need to get these headers and continue routing normally, one single branch.

Regards,

David Villasmil
email: david.villasmil.work at gmail.com<mailto:david.villasmil.work at gmail.com>
phone: +34669448337


On Mon, Jun 14, 2021 at 11:12 PM Jeff Pyle <jeff at ugnd.org<mailto:jeff at ugnd.org>> wrote:
Add it in a branch_route.  That way if you have to route advance, it'll already be gone because you'll be on a new branch.


- Jeff


On Mon, Jun 14, 2021 at 5:52 PM David Villasmil <david.villasmil.work at gmail.com<mailto:david.villasmil.work at gmail.com>> wrote:
Hello guys,

So, I'm appending a header (append_hf("header")) to a forward.
That forward fails and I'm trying to remove it with remove_hf("header"), but it's not getting removed for some reason, what am I doing wrong?

Thanks everyone!

David Villasmil
email: david.villasmil.work at gmail.com<mailto:david.villasmil.work at gmail.com>
phone: +34669448337
_______________________________________________
Users mailing list
Users at lists.opensips.org<mailto:Users at lists.opensips.org>
http://lists.opensips.org/cgi-bin/mailman/listinfo/users<http://lists.opensips.org/cgi-bin/mailman/listinfo/users>
_______________________________________________
Users mailing list
Users at lists.opensips.org<mailto:Users at lists.opensips.org>
http://lists.opensips.org/cgi-bin/mailman/listinfo/users<http://lists.opensips.org/cgi-bin/mailman/listinfo/users>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20210615/77816035/attachment.html>


More information about the Users mailing list