[asterisk-dev] reset/remove SipAddHeader() headers
Klaus Darilion
klaus.mailinglists at pernau.at
Tue Jan 20 02:05:22 CST 2009
Leif Madsen schrieb:
>
> Klaus Darilion wrote:
>> John Todd schrieb:
>>> Even in the instance where a 500 is received and somehow the dialplan
>>> is re-entered, it seems burdensome to remove ALL headers and start
>>> from scratch. Wouldn't you just want to remove the specific header
>>> that is causing problems? This would imply some sort of indexing, or
>>> at the minimum, regexp-style string matching so I could say:
>>>
>>> exten => _X11.,SipRemoveHeader(X-PSAP-ID)
>>>
>>> which would remove both of these headers:
>>>
>>> X-PSAP-ID: 33-MONTCOPA-PRIMARY-9929312311AA
>>> X-PSAP-ID: 33-MONTCOPA-BACK-99283122833CD
>> I submitted a patch which also takes at least some of your ideas - to
>> remove selectively too: http://bugs.digium.com/view.php?id=14246
>>
>>
>> For example you have added these 2 headers:
>> SIPAddHeader(P-Asserted-Identity: sip:foo at bar);
>> SIPAddHeader(P-Preferred-Identity: sip:bar at foo);
>>
>> // remove all headers
>> SIPRemoveHeader();
>>
>> // remove all P- headers
>> SIPRemoveHeader(P-);
>>
>> // remove one the PAI header (note the : at the end)
>> SIPRemoveHeader(P-Asserted-Identity:);
>
>
> What about programming it in such a way that you can get the number of
> results that match your criteria, then that would allow you to parse
> through the headers that match, and then you can filter out the ones you
> want.
Hi Leif!
This would be possible, but I think that it makes things too
complicated. The SIPRemoveHeader function removes only headers which
were previously added with SIPAddHeader. Thus, the script writer usually
knows which headers he had added before, and remove either all of them
or just selected ones, but regardless of there value - just based on the
header name.
regards
klaus
>
> I'm thinking about how the DUNDIQUERY() and DUNDIRESULT() functions work
> (see them for more information about the syntax I'm using below). Here
> is a little dialplan code that would go through, get the number SIP
> headers that started with P-, check if the value of the header was
> 'sip:foo at bar', and if so, remove that header. If not, then move onto the
> next header, until no more exist.
>
> Set(HEADER_RES=${SIP_HEADER_QUERY(P-)})
> Set(HEADER_COUNT=${SIP_HEADER_RESULT(${HEADER_RES},getnum)}) ;
> (Result returns say 2)
>
>
>
> Verbose(2,Removing all headers starting with P- and a value of
> sip:foo at bar)
> Set(X=1)
> While($[${HEADER_COUNT} <= ${X}])
> Set(CURRENT_HEADER=${SIP_HEADER_RESULT(${HEADER_RES},${X})})
> ExecIf($["${CURRENT_HEADER}" = "sip:foo at bar"]?SIPRemoveHeader(P-,${X}))
> Verbose(2,${IF($[${CURRENT_HEADER}" =
> "sip:foo at bar"]?Verbose(2,Header removed:No header modification))
> Set(X=$[${X} + 1])
> EndWhile()
> Verbose(2,Headers removal complete)
>
>
>
> Thanks!
> Leif Madsen
> http://www.leifmadsen.com
> http://www.asteriskdocs.org
>
> _______________________________________________
> --Bandwidth and Colocation Provided by http://www.api-digital.com--
>
> asterisk-dev mailing list
> To UNSUBSCRIBE or update options visit:
> http://lists.digium.com/mailman/listinfo/asterisk-dev
More information about the asterisk-dev
mailing list