<div dir="auto">Thank you Daniel.<div dir="auto"><br></div><div dir="auto">Is it safe to use remove_hf("User-Agent") without check if this header exist?</div><div dir="auto">or better use if(is_present_hf("User-Agent")) { <span style="font-family:sans-serif">remove_hf("User-Agent"); } ?</span></div><div dir="auto"><span style="font-family:sans-serif"><br></span></div><div dir="auto"><span style="font-family:sans-serif">Thank you.</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">25 нояб. 2016 г. 2:56 PM пользователь "Daniel Tryba" <<a href="mailto:d.tryba@pocos.nl" target="_blank">d.tryba@pocos.nl</a>> написал:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Fri, Nov 25, 2016 at 02:08:07PM +0200, Sergey Basov wrote:<br>
> Hello All.<br>
><br>
> I have some troubles with upstream sip switch.<br>
> It ignores SIP packets which contains:<br>
><br>
> User-Agent: FPBX-2.11.0(11.17.1)<br>
> or<br>
> Server: User-Agent: FPBX-2.11.0(11.17.1)<br>
><br>
> If space is present before first "(" then sip switch works as expected<br>
><br>
> So my question is: how corektly make analyze and modify this headers<br>
> using kamailio?<br>
> In which routes i must parse it?<br>
<br>
Since you need to remove the headers first before replacing it if you<br>
wish, you'll need the textops remove_hf function:<br>
<a href="http://kamailio.org/docs/modules/stable/modules/textops.html#textops.f.remove_hf" rel="noreferrer" target="_blank">http://kamailio.org/docs/<wbr>modules/stable/modules/<wbr>textops.html#textops.f.remove_<wbr>hf</a><br>
which can be used in REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE and<br>
BRANCH_ROUTE.<br>
<br>
If you really want to bother to change these headers you could do<br>
something like<br>
<br>
$var(ua)=$hdr(User-Agent);<br>
$var(ua)=$(var(ua){re.subst,/(<wbr>.*)(\(.*\))(.*)/\1 \2\3/});<br>
remove_hf("User-Agent");<br>
append_hf("USer-Agent: $var(ua)\r\n");<br>
<br>
Which blindly replaces the "(foo)" string by " (foo)" regardless of the<br>
char before the first "(".<br>
<br>
But use the KISS approach: just delete the headers<br>
<br>
______________________________<wbr>_________________<br>
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br>
<a href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">http://lists.sip-router.org/<wbr>cgi-bin/mailman/listinfo/sr-<wbr>users</a><br>
</blockquote></div></div>