Merge pull request #137 in FS/freeswitch from bugfix/FS-7061-add-q-header-param-on-300-responses to master

* commit '21458f85cc4228e54151350dd89c5c87cc3dfef4':
  FS-7062: [mod_sofia] on redirect, when uri are passed in without <> with multiple uris, automatically add the q= header param in decending order.  This should make 300 Multiple Choices work well with devices that require the q param.  If you would like to specify explicit q-values, please use the syntax of redirect where you specify the entire header using the <>
This commit is contained in:
Mike Jerris 2014-12-09 11:57:34 -06:00
commit fb59217f3e
1 changed files with 16 additions and 4 deletions

View File

@ -1828,11 +1828,13 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
break; break;
case SWITCH_MESSAGE_INDICATE_REDIRECT: case SWITCH_MESSAGE_INDICATE_REDIRECT:
#define MAX_REDIR 128
if (!zstr(msg->string_arg)) { if (!zstr(msg->string_arg)) {
if (!switch_channel_test_flag(channel, CF_ANSWERED) && !sofia_test_flag(tech_pvt, TFLAG_BYE)) { if (!switch_channel_test_flag(channel, CF_ANSWERED) && !sofia_test_flag(tech_pvt, TFLAG_BYE)) {
char *dest = (char *) msg->string_arg; char *dest = (char *) msg->string_arg;
char *argv[128] = { 0 }; char *argv[MAX_REDIR] = { 0 };
char *mydata = NULL, *newdest = NULL; char *mydata = NULL, *newdest = NULL;
int argc = 0, i; int argc = 0, i;
switch_size_t len = 0; switch_size_t len = 0;
@ -1846,10 +1848,20 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
if (!strchr(argv[i], '<') && !strchr(argv[i], '>')) { if (!strchr(argv[i], '<') && !strchr(argv[i], '>')) {
if (i == argc - 1) { if (argc > 1) {
switch_snprintf(newdest + strlen(newdest), len - strlen(newdest), "\"unknown\" <%s>", argv[i]); if (i == argc - 1) {
switch_snprintf(newdest + strlen(newdest), len - strlen(newdest), "\"unknown\" <%s>;q=%1.3f",
argv[i], (double)((double)(MAX_REDIR + 1 - i))/1000);
} else {
switch_snprintf(newdest + strlen(newdest), len - strlen(newdest), "\"unknown\" <%s>;q=%1.3f,",
argv[i], (double)((double)(MAX_REDIR + 1 - i))/1000);
}
} else { } else {
switch_snprintf(newdest + strlen(newdest), len - strlen(newdest), "\"unknown\" <%s>,", argv[i]); if (i == argc - 1) {
switch_snprintf(newdest + strlen(newdest), len - strlen(newdest), "\"unknown\" <%s>", argv[i]);
} else {
switch_snprintf(newdest + strlen(newdest), len - strlen(newdest), "\"unknown\" <%s>,", argv[i]);
}
} }
} else { } else {
if (i == argc - 1) { if (i == argc - 1) {