diff --git a/src/modules/imc/imc.c b/src/modules/imc/imc.c index e9208731655..47216ba2cc1 100644 --- a/src/modules/imc/imc.c +++ b/src/modules/imc/imc.c @@ -54,7 +54,7 @@ MODULE_VERSION /** header variables */ -str imc_hdrs = str_init("Content-Type: text/plain\r\nSupported: kamailio/imc\r\n"); +str imc_hdrs = str_init("Supported: kamailio/imc\r\n"); char hdr_buf[1024]; str all_hdrs; @@ -435,7 +435,7 @@ static int ki_imc_manager(struct sip_msg* msg) } goto done; - } + } if(imc_handle_message(msg, &body, &src, &dst)<0) { diff --git a/src/modules/imc/imc_cmd.c b/src/modules/imc/imc_cmd.c index adff66e24f8..ea76e798162 100644 --- a/src/modules/imc/imc_cmd.c +++ b/src/modules/imc/imc_cmd.c @@ -91,29 +91,37 @@ static str *get_callid(struct sip_msg *msg) static str *build_headers(struct sip_msg *msg) { + static str ctname = STR_STATIC_INIT("Content-Type: "); static str name = STR_STATIC_INIT("In-Reply-To: "); + static str nl = STR_STATIC_INIT("\r\n"); static char buf[1024]; static str rv; str *callid; - if ((callid = get_callid(msg)) == NULL) - return &all_hdrs; - rv.s = buf; - rv.len = all_hdrs.len + name.len + callid->len; + rv.len = all_hdrs.len + ctname.len + msg->content_type->body.len; + + memcpy(buf, all_hdrs.s, all_hdrs.len); + memcpy(buf + all_hdrs.len, ctname.s, ctname.len); + memcpy(buf + all_hdrs.len + ctname.len, msg->content_type->body.s, msg->content_type->body.len); + + if ((callid = get_callid(msg)) == NULL) { + return &rv; + } + + rv.len += nl.len + name.len + callid->len; if (rv.len > sizeof(buf)) { LM_ERR("Header buffer too small for In-Reply-To header\n"); - return &all_hdrs; + return &rv; } - - memcpy(buf, all_hdrs.s, all_hdrs.len); - memcpy(buf + all_hdrs.len, name.s, name.len); - memcpy(buf + all_hdrs.len + name.len, callid->s, callid->len); + + memcpy(buf + all_hdrs.len + ctname.len + msg->content_type->body.len, nl.s, nl.len); + memcpy(buf + all_hdrs.len + ctname.len + msg->content_type->body.len + nl.len, name.s, name.len); + memcpy(buf + all_hdrs.len + ctname.len + msg->content_type->body.len + nl.len + name.len, callid->s, callid->len); return &rv; } - static str *format_uri(str uri) { static char buf[512];