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@lists.sip-router.org [mailto:sr-users-bounces@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 listsr-users@lists.sip-router.orghttp://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