[SR-Users] $(hdr(name)[N]) question
miconda at gmail.com
Mon Apr 28 09:44:28 CEST 2014
On 25/04/14 16:15, Juha Heinanen wrote:
> Juha Heinanen writes:
>> wiki was this related to $(hdr(name)[N]):
>> If [N] is omitted then the body of the first header is printed. The
>> first header is got when N=0, for the second N=1, a.s.o. In case of a
>> comma-separated multi-body headers, it returns all the bodies,
>> i don't understand the last sentence. how can i get all bodies of all
>> headers of name=x as a comma separated list?
> perhaps the above "In case" sentence should read:
> In case of comma-separated multi-body headers, $(hdr(name)[*]) returns
> all the bodies, comma-separated.
> while testing this, i found a bug. when incoming request has
> Test: <sip:user1 at foo.bar>.
> Test: <sip:user2 at foo.bar>,<sip:user3 at foo.bar>.
> xlog("L_INFO", "Test '$(hdr(test)[*])'\n");
> Apr 25 17:11:37 siika /usr/sbin/sip-proxy: INFO: Test '<sip:user1 at foo.bar>, <sip:user2 at foo.bar>,<sip:user3 at foo.bar>'
> the bug is the extra space char after first comma.
I guess the $hdr(X[*]) uses comma-space for separation (haven't checked
the sources). In your example, the second header test has two values in
one line and $hdr(...) is simply returning all of them.
If you would have:
Test: <sip:user1 at foo.bar>.
Test: <sip:user2 at foo.bar>,<sip:user3 at foo.bar>.
Test: <sip:user4 at foo.bar>.
Probably the result would be:
'<sip:user1 at foo.bar>, <sip:user2 at foo.bar>,<sip:user3 at foo.bar>,
<sip:user4 at foo.bar>'
Daniel-Constantin Mierla - http://www.asipto.com
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
More information about the sr-users