Summary:ASTERISK-21815: SipRemoveHeader does not remove previously added Alert-Info Header
Reporter:Peter Katzmann (pk16208)Labels:
Date Opened:2013-05-24 06:38:31Date Closed:2013-05-24 13:51:10
Versions: 10.12.2 Frequency of
Environment:ubunue 10.04Attachments:( 0) full
we tried to remove a previously added alert-info header element to avoid wrong ringtones during call forwarding.
I tried several incarnations of SipRemoveHeader(Alert-Info:), Alert-Info, Alert-
But the info element is still in the header
Comments:By: Peter Katzmann (pk16208) 2013-05-24 06:39:13.838-0500

Logfile with dialplan and sip flow

By: Rusty Newton (rnewton) 2013-05-24 13:50:12.365-0500

This took me a bit to notice after attempting to reproduce.

You add the header, improperly including the quotes: (notice the double quotes, ""Alert-Info: ...)
[May 24 13:32:56] VERBOSE[14760] res_agi.c:     -- AGI Script Executing Application: (SipAddHeader) Options: ("Alert-Info: <>")
[May 24 13:32:56] DEBUG[14760] chan_sip.c: SIP Header added ""Alert-Info: <>"" as __SIPADDHEADER02

When you are attempting to remove the header you don't include any quotes:
[May 24 13:32:56] VERBOSE[14760] pbx.c:     -- Executing [2205@macro-dial-localext:55] SIPRemoveHeader("SIP/2202-0000010a", "Alert-Info:") in new stack

The SipRemoveHeader application, when supplied with a parameter matches from the beginning of the string. From the help text:

If a parameter is supplied, only the matching headers will
be removed.
For example you have added these 2 headers:
SIPAddHeader(P-Asserted-Identity: sip:foo@bar);
SIPAddHeader(P-Preferred-Identity: sip:bar@foo);
// remove all headers
// remove all P- headers
// remove only the PAI header (note the : at the end)
Always returns '0'.

Remove the quotes and you should be good.

By: Peter Katzmann (pk16208) 2013-05-27 05:23:54.307-0500

You are right, the agi had double quotes.

But as a side thought, why does asterisk silently remove the quotes in the SIP Header ?

By: Rusty Newton (rnewton) 2013-06-05 14:54:01.044-0500

bq. But as a side thought, why does asterisk silently remove the quotes in the SIP Header ?

I don't understand the question. Asterisk doesn't remove any quotes. It was keeping the quotes that were sent to it.

The quotes you see in debug exist to denote that string. As in the quotes you see below:
SIPRemoveHeader("SIP/2202-0000010a", "Alert-Info:")

If you mean that Asterisk is removing the unintentional quotes before it sends out the SIP message.. I don't know. You could ask in #asterisk-dev or on the dev list