[SR-Users] How to find whether or not certain header exists?

Allen Zhang Allen.Zhang at imgtec.com
Thu Jun 26 23:01:29 CEST 2014


Thanks Daniel.
I didn’t know “$null” existed. But I’ll use is_present_hf since I’m not interested in the contain of the header.

From: sr-users-bounces at lists.sip-router.org [mailto:sr-users-bounces at lists.sip-router.org] On Behalf Of Daniel-Constantin Mierla
Sent: Thursday, 26 June 2014 7:57 p.m.
To: Kamailio (SER) - Users Mailing List
Subject: Re: [SR-Users] How to find whether or not certain header exists?

Hello,

you can use:

if(is_present_hf("aaa")) ...

Also, it should work like:

if($hdr("aaa") != $null) ...

The is_present_hf() should be slightly faster as it just walks through the list of headers, not parsing the header body and not returning its value.

Cheers,
Daniel
On 26/06/14 06:35, Allen Zhang wrote:
Hi,

If I normally receive a INVITE that has a header ‘aaa’ with value ‘bbb’, but it’s possible that some INVITEs don’t have this header.
How do I determine in the config file if the header exists?
To check the value of the header I do if($hdr(aaa) == "bbb"). But what if the header doesn’t exist?

Cheer,
Allen






_______________________________________________

SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list

sr-users at lists.sip-router.org<mailto:sr-users at lists.sip-router.org>

http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users



--

Daniel-Constantin Mierla - http://www.asipto.com

http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20140626/815872ba/attachment.html>


More information about the sr-users mailing list