Changeset 5569


Ignore:
Timestamp:
Mar 21, 2017 7:19:43 AM (7 years ago)
Author:
nanang
Message:

Close #2003: Added API pjsip_multipart_get_raw() to get raw body of a multipart message body.

Location:
pjproject/trunk/pjsip
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/include/pjsip/sip_multipart.h

    r3553 r5569  
    171171 
    172172/** 
     173 * Get the boundary string and the raw message body of the specified 
     174 * multipart message body. Note that raw message body will only be available 
     175 * if the multipart message body is generated by pjsip_multipart_parse(). 
     176 * 
     177 * @param mp            The multipart message body. 
     178 * @param boundary      Optional parameter to receive the boundary string. 
     179 * @param raw_data      Optional parameter to receive the raw message body. 
     180 * 
     181 * @return              PJ_SUCCESS on success. 
     182 */ 
     183PJ_DECL(pj_status_t) pjsip_multipart_get_raw(pjsip_msg_body *mp, 
     184                                             pj_str_t *boundary, 
     185                                             pj_str_t *raw_data); 
     186 
     187/** 
    173188 * @}  PJSIP_MULTIPART 
    174189 */ 
  • pjproject/trunk/pjsip/src/pjsip/sip_multipart.c

    r5545 r5569  
    4646    pj_str_t              boundary; 
    4747    pjsip_multipart_part  part_head; 
     48    pj_str_t              raw_data; 
    4849}; 
    4950 
     
    609610    body = pjsip_multipart_create(pool, ctype, &boundary); 
    610611 
     612    /* Save full raw body */ 
     613    { 
     614        struct multipart_data *mp = (struct multipart_data*)body->data; 
     615        pj_strset(&mp->raw_data, buf, len); 
     616    } 
     617 
    611618    for (;;) { 
    612619        char *start_body, *end_body; 
     
    668675} 
    669676 
     677 
     678PJ_DEF(pj_status_t) pjsip_multipart_get_raw( pjsip_msg_body *mp, 
     679                                             pj_str_t *boundary, 
     680                                             pj_str_t *raw_data) 
     681{ 
     682    struct multipart_data *m_data; 
     683 
     684    /* Must specify mandatory params */ 
     685    PJ_ASSERT_RETURN(mp, PJ_EINVAL); 
     686 
     687    /* mp must really point to an actual multipart msg body */ 
     688    PJ_ASSERT_RETURN(mp->print_body==&multipart_print_body, PJ_EINVAL); 
     689 
     690    m_data = (struct multipart_data*)mp->data; 
     691 
     692    if (boundary) 
     693        *boundary = m_data->boundary; 
     694 
     695    if (raw_data) 
     696        *raw_data = m_data->raw_data; 
     697 
     698    return PJ_SUCCESS; 
     699} 
Note: See TracChangeset for help on using the changeset viewer.