[prev in list] [next in list] [prev in thread] [next in thread] 

List:       serusers
Subject:    Re: [SR-Users] How to find whether or not certain header exists?
From:       Allen Zhang <Allen.Zhang () imgtec ! com>
Date:       2014-06-26 21:01:29
Message-ID: 04588C075527D74CABD19E7C320BCB1C08046370 () WEMAIL01 ! we ! imgtec ! org
[Download RAW message or body]

[Attachment #2 (text/plain)]

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 list

sr-users@lists.sip-router.org<mailto:sr-users@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


[Attachment #3 (text/html)]

<html xmlns:v="urn:schemas-microsoft-com:vml" \
xmlns:o="urn:schemas-microsoft-com:office:office" \
xmlns:w="urn:schemas-microsoft-com:office:word" \
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" \
xmlns="http://www.w3.org/TR/REC-html40"> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
	{font-family:Consolas;
	panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";
	color:black;
	mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:purple;
	text-decoration:underline;}
pre
	{mso-style-priority:99;
	mso-style-link:"HTML Preformatted Char";
	margin:0cm;
	margin-bottom:.0001pt;
	font-size:10.0pt;
	font-family:"Courier New";
	color:black;}
span.EmailStyle17
	{mso-style-type:personal;
	font-family:"Calibri","sans-serif";
	color:windowtext;}
span.HTMLPreformattedChar
	{mso-style-name:"HTML Preformatted Char";
	mso-style-priority:99;
	mso-style-link:"HTML Preformatted";
	font-family:Consolas;
	color:black;
	mso-fareast-language:EN-US;}
span.EmailStyle20
	{mso-style-type:personal-reply;
	font-family:"Calibri","sans-serif";
	color:#1F497D;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-size:10.0pt;}
@page WordSection1
	{size:612.0pt 792.0pt;
	margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor="white" lang="EN-NZ" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:#1F497D">Thanks Daniel.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">I didn't know "$null" existed. But \
I'll use is_present_hf since I'm not interested in the contain of the \
header.<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="color:#1F497D"><o:p>&nbsp;</o:p></span></p> <div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" \
style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;;color:windowtext;mso-fareast-language:EN-NZ">From:</span></b><span \
lang="EN-US" style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;;color:windowtext;mso-fareast-language:EN-NZ">
  sr-users-bounces@lists.sip-router.org \
[mailto:sr-users-bounces@lists.sip-router.org] <b>On Behalf Of </b>Daniel-Constantin \
Mierla<br> <b>Sent:</b> Thursday, 26 June 2014 7:57 p.m.<br>
<b>To:</b> Kamailio (SER) - Users Mailing List<br>
<b>Subject:</b> Re: [SR-Users] How to find whether or not certain header \
exists?<o:p></o:p></span></p> </div>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">Hello,<br>
<br>
you can use:<br>
<br>
if(is_present_hf(&quot;aaa&quot;)) ...<br>
<br>
Also, it should work like:<br>
<br>
if($hdr(&quot;aaa&quot;) != $null) ...<br>
<br>
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.<br> <br>
Cheers,<br>
Daniel<o:p></o:p></p>
<div>
<p class="MsoNormal">On 26/06/14 06:35, Allen Zhang wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">Hi,<o:p></o:p></p>
<p class="MsoNormal">&nbsp;<o:p></o:p></p>
<p class="MsoNormal">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.<o:p></o:p></p> <p class="MsoNormal">How do I determine in the config file if \
the header exists?<o:p></o:p></p> <p class="MsoNormal">To check the value of the \
header I do if($hdr(aaa) == &quot;bbb&quot;). But what if the header doesn't \
exist?<o:p></o:p></p> <p class="MsoNormal">&nbsp;<o:p></o:p></p>
<p class="MsoNormal">Cheer,<o:p></o:p></p>
<p class="MsoNormal">Allen<o:p></o:p></p>
<p class="MsoNormal">&nbsp;<o:p></o:p></p>
<p class="MsoNormal">&nbsp;<o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New \
Roman&quot;,&quot;serif&quot;;mso-fareast-language:EN-NZ"><br> <br>
<br>
<o:p></o:p></span></p>
<pre>_______________________________________________<o:p></o:p></pre>
<pre>SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing \
list<o:p></o:p></pre> <pre><a \
href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><o:p></o:p></pre>
 <pre><a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><o:p></o:p></pre>
 </blockquote>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New \
Roman&quot;,&quot;serif&quot;;mso-fareast-language:EN-NZ"><br> <br>
<o:p></o:p></span></p>
<pre>-- <o:p></o:p></pre>
<pre>Daniel-Constantin Mierla - <a \
href="http://www.asipto.com">http://www.asipto.com</a><o:p></o:p></pre> <pre><a \
href="http://twitter.com/#!/miconda">http://twitter.com/#!/miconda</a> - <a \
href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a><o:p></o:p></pre>
 </div>
</body>
</html>



_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

--===============0494325170==--


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic