[sr-dev] git:master:3cab2dd0: imc: propagate content-type header

Daniel-Constantin Mierla miconda at gmail.com
Wed Dec 7 14:22:05 CET 2022


Module: kamailio
Branch: master
Commit: 3cab2dd0d2802bf33d0e76cc81a3b40f70611cda
URL: https://github.com/kamailio/kamailio/commit/3cab2dd0d2802bf33d0e76cc81a3b40f70611cda

Author: Joey Golan <joeygo at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2022-12-07T14:21:57+01:00

imc: propagate content-type header

---

Modified: src/modules/imc/imc.c
Modified: src/modules/imc/imc_cmd.c

---

Diff:  https://github.com/kamailio/kamailio/commit/3cab2dd0d2802bf33d0e76cc81a3b40f70611cda.diff
Patch: https://github.com/kamailio/kamailio/commit/3cab2dd0d2802bf33d0e76cc81a3b40f70611cda.patch

---

diff --git a/src/modules/imc/imc.c b/src/modules/imc/imc.c
index e920873165..47216ba2cc 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 adff66e24f..ea76e79816 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];




More information about the sr-dev mailing list