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,
comma-separated.
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@foo.bar>.
Test: <sip:user2@foo.bar>,<sip:user3@foo.bar>.
xlog("L_INFO", "Test '$(hdr(test)[*])'\n");
produces:
Apr 25 17:11:37 siika /usr/sbin/sip-proxy[9801]: INFO: Test
'<sip:user1@foo.bar>, <sip:user2@foo.bar>,<sip:user3@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@foo.bar>.
Test: <sip:user2@foo.bar>,<sip:user3@foo.bar>.
Test: <sip:user4@foo.bar>.
Probably the result would be:
'<sip:user1@foo.bar>, <sip:user2@foo.bar>,<sip:user3@foo.bar>,
<sip:user4@foo.bar>'
Cheers,
Daniel
--
Daniel-Constantin Mierla -
http://www.asipto.com
http://twitter.com/#!/miconda -
http://www.linkedin.com/in/miconda