From: Brian West Date: Thu, 2 Dec 2010 22:55:02 +0000 (-0600) Subject: FS-2881: SIP-header History-Info might exist multiple times, but only last header... X-Git-Tag: v1.2-rc1~243^2^2~6^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8cf1501203de1481089d3576333fe10278da23fe;p=thirdparty%2Ffreeswitch.git FS-2881: SIP-header History-Info might exist multiple times, but only last header is exposed as a channel variable --- diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index e20d868548..2e13b544d0 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -7001,6 +7001,8 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ if (tech_pvt->caller_profile) { + int first_history_info = 1; + if (rpid) { if (rpid->rpid_privacy) { if (!strcasecmp(rpid->rpid_privacy, "yes")) { @@ -7045,7 +7047,25 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_ } } } else if (!strncasecmp(un->un_name, "History-Info", 12)) { - switch_channel_set_variable(channel, "sip_history_info", un->un_value); + if (first_history_info) { + /* If the header exists first time, make sure to remove old info and re-set the variable */ + switch_channel_set_variable(channel, "sip_history_info", un->un_value); + first_history_info = 0; + } else { + /* Append the History-Info into one long string */ + const char *history_var = switch_channel_get_variable(channel, "sip_history_info"); + if (!zstr(history_var)) { + char *tmp_str; + if ((tmp_str = switch_mprintf("%s, %s", history_var, un->un_value))) { + switch_channel_set_variable(channel, "sip_history_info", tmp_str); + free(tmp_str); + } else { + switch_channel_set_variable(channel, "sip_history_info", un->un_value); + } + } else { + switch_channel_set_variable(channel, "sip_history_info", un->un_value); + } + } } else if (!strcasecmp(un->un_name, "X-FS-Support")) { tech_pvt->x_freeswitch_support_remote = switch_core_session_strdup(session, un->un_value); } else if (!strncasecmp(un->un_name, "X-", 2) || !strncasecmp(un->un_name, "P-", 2)) {