]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip: Allow global headers to be overridden. 40/3840/2
authorJoshua Colp <jcolp@digium.com>
Wed, 7 Sep 2016 21:00:16 +0000 (21:00 +0000)
committerJoshua Colp <jcolp@digium.com>
Wed, 7 Sep 2016 21:01:30 +0000 (21:01 +0000)
Currently when you add global headers from the dialplan both
the header in the dialplan and the globally configured header
are added to the resulting SIP INVITE. This change makes it
so the headers in the dialplan take precedence and are the
only ones added.

Change-Id: I36f864298f38db3632ad503edc11267cb8ffb3ad

res/res_pjsip/pjsip_global_headers.c

index 735008dcc8bf4d8adbbe14a2dc224f250650007a..501f5f5237dbcce4ec96abdc1610772afa730f2f 100644 (file)
@@ -87,6 +87,14 @@ static void add_headers_to_message(struct header_list *headers, pjsip_tx_data *t
                return;
        }
        AST_LIST_TRAVERSE(headers, iter, next) {
+               pj_str_t name;
+               pjsip_generic_string_hdr *hdr;
+
+               hdr = pjsip_msg_find_hdr_by_name(tdata->msg, pj_cstr(&name, iter->name), NULL);
+               if (hdr) {
+                       continue;
+               }
+
                ast_sip_add_header(tdata, iter->name, iter->value);
        };
        tdata->mod_data[global_header_mod.id] = &handled_id;