This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
tutorials:faq:main [2019/11/19 15:50] miconda |
tutorials:faq:main [2020/10/15 08:31] miconda |
||
---|---|---|---|
Line 191: | Line 191: | ||
</ | </ | ||
+ | ??? Why parts of From/To header appear many times? | ||
+ | |||
+ | !!! After doing header management operations, it can result that parts of From/To header are duplicated or the result is the concatenation of many values. That is related to previous question, because the changes are not applied immediately and updates to parts of headers are not a simple set operation. | ||
+ | |||
+ | For example, if From username is " | ||
+ | |||
+ | <code c> | ||
+ | $fU = " | ||
+ | ... | ||
+ | $fU = " | ||
+ | </ | ||
+ | |||
+ | The result can be that From username is " | ||
+ | |||
+ | One solution is to use **msg_apply_changes()** in between: | ||
+ | |||
+ | <code c> | ||
+ | $fU = " | ||
+ | msg_apply_changes(); | ||
+ | ... | ||
+ | $fU = " | ||
+ | </ | ||
+ | |||
+ | Another solution is to keep the value in a variable (e.g., avp or xavp) and do the operation only once, like: | ||
+ | |||
+ | <code c> | ||
+ | $xavp(fU) = " | ||
+ | ... | ||
+ | $xavp(fU[0]) = " | ||
+ | ... | ||
+ | $fU = $xavp(fU); | ||
+ | </ | ||
+ | |||
+ | Updating From/To headers is recommended to be done in **branch_route**, | ||
+ | |||
+ | The examples above were with assignments to $fU (can be other vars as well, such as $fu, $tU, $tu, ..), but it is the same behaviour when using functions such as uac_replace_from() or uac_replace_to(). | ||
??? How to set different header values for each destination of a SIP request? | ??? How to set different header values for each destination of a SIP request? | ||
Line 516: | Line 552: | ||
??? How to iterate through the items in a comma separated string? | ??? How to iterate through the items in a comma separated string? | ||
- | !!! If you have a variable holding a string like " | + | !!! If you have a variable holding a string like " |
Here is an example: | Here is an example: |