Changeset 5545


Ignore:
Timestamp:
Jan 24, 2017 5:59:05 AM (8 years ago)
Author:
riza
Message:

Re #1945 (misc): Prevent automatically adding Content-Type and Content-Length on
printing multipart data when its already printed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsip/sip_multipart.c

    r5170 r5545  
    6868        char *clen_pos; 
    6969        const pjsip_hdr *hdr; 
     70        pj_bool_t ctype_printed = PJ_FALSE; 
    7071 
    7172        clen_pos = NULL; 
     
    8384        while (hdr != &part->hdr) { 
    8485            int printed = pjsip_hdr_print_on((pjsip_hdr*)hdr, p, 
    85                                              SIZE_LEFT()-2); 
     86                                             SIZE_LEFT()-2); 
    8687            if (printed < 0) 
    8788                return -1; 
     
    8990            *p++ = '\r'; 
    9091            *p++ = '\n'; 
     92 
     93            if (!ctype_printed && hdr->type == PJSIP_H_CONTENT_TYPE) 
     94                ctype_printed = PJ_TRUE;             
     95 
    9196            hdr = hdr->next; 
    9297        } 
    9398 
    9499        /* Automaticly adds Content-Type and Content-Length headers, only 
    95          * if content_type is set in the message body. 
     100         * if content_type is set in the message body and haven't been printed. 
    96101         */ 
    97         if (part->body && part->body->content_type.type.slen) { 
     102        if (part->body && part->body->content_type.type.slen && !ctype_printed)  
     103        { 
    98104            pj_str_t ctype_hdr = { "Content-Type: ", 14}; 
    99105            const pjsip_media_type *media = &part->body->content_type; 
Note: See TracChangeset for help on using the changeset viewer.