summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRiza Sulistyo <riza@teluu.com>2017-01-24 05:59:05 +0000
committerRiza Sulistyo <riza@teluu.com>2017-01-24 05:59:05 +0000
commit973a24516f2c8ac18a5ad1d1cc2ffdc7fd09d289 (patch)
treefd99405f3eaa939d39eb442341b4c0ba22bc54ff
parent377a01b2a7f9df963c0501eab30df7f8c64686f4 (diff)
Re #1945 (misc): Prevent automatically adding Content-Type and Content-Length on
printing multipart data when its already printed. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@5545 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjsip/src/pjsip/sip_multipart.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/pjsip/src/pjsip/sip_multipart.c b/pjsip/src/pjsip/sip_multipart.c
index 9c7aea64..b6a50d0b 100644
--- a/pjsip/src/pjsip/sip_multipart.c
+++ b/pjsip/src/pjsip/sip_multipart.c
@@ -67,6 +67,7 @@ static int multipart_print_body(struct pjsip_msg_body *msg_body,
enum { CLEN_SPACE = 5 };
char *clen_pos;
const pjsip_hdr *hdr;
+ pj_bool_t ctype_printed = PJ_FALSE;
clen_pos = NULL;
@@ -82,19 +83,24 @@ static int multipart_print_body(struct pjsip_msg_body *msg_body,
hdr = part->hdr.next;
while (hdr != &part->hdr) {
int printed = pjsip_hdr_print_on((pjsip_hdr*)hdr, p,
- SIZE_LEFT()-2);
+ SIZE_LEFT()-2);
if (printed < 0)
return -1;
p += printed;
*p++ = '\r';
*p++ = '\n';
+
+ if (!ctype_printed && hdr->type == PJSIP_H_CONTENT_TYPE)
+ ctype_printed = PJ_TRUE;
+
hdr = hdr->next;
}
/* Automaticly adds Content-Type and Content-Length headers, only
- * if content_type is set in the message body.
+ * if content_type is set in the message body and haven't been printed.
*/
- if (part->body && part->body->content_type.type.slen) {
+ if (part->body && part->body->content_type.type.slen && !ctype_printed)
+ {
pj_str_t ctype_hdr = { "Content-Type: ", 14};
const pjsip_media_type *media = &part->body->content_type;