I'm adding and removing headers in the standard route[RELAY], but if there is a redirection involved headers aren't removed.
route[RELAY] { #stdstuff route(ADDCHECKSUM);
# enable additional event routes for forwarded requests # - serial forking, RTP relaying handling, a.s.o. if (is_method("INVITE|SUBSCRIBE")) { t_on_branch("MANAGE_BRANCH"); t_on_reply("MANAGE_REPLY"); } if (is_method("INVITE")) { t_on_failure("MANAGE_FAILURE"); }
if (!t_relay()) { sl_reply_error(); } exit; }
route[ADDCHECKSUM] { if($avp(dst_accountcode) || $avp(src_accountcode)) { #some magic remove_hf("X-rand"); remove_hf("X-csum");
append_hf("X-rand: $var(rand)\r\n"); append_hf("X-csum: $var(checksum)\r\n"); }
return; }
This works well unless the destination is a redirecting sip server.
failure_route[MANAGE_FAILURE] { route(NATMANAGE);
if (t_is_canceled()) { exit; }
if (t_check_status("3[0-9][0-9]")) { #... route(RELAY); exit; }
-user calls destination. -dispatcher sets destination is send to redirectserver and routes to RELAY, addchecksums add some headers called from relay. -redirectserver replies 302. -failure route triggers and ends with a route to RELAY. Any existing old values should be removed and the newer ones added.
But end the result is that I have two sets op X-rand/csum headers for the INVITE to the redirection contact. How do I get rid of every X-csum/rand header except the last added ones?
Version tested: 4.2.5.