Commit a647915e authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Fixed issue with custom boundary

parent 883c11eb
......@@ -94,6 +94,7 @@ BELLESIP_EXPORT void belle_sip_file_body_handler_set_user_body_handler(belle_sip
*/
#define BELLE_SIP_MULTIPART_BODY_HANDLER(obj) BELLE_SIP_CAST(obj,belle_sip_multipart_body_handler_t)
BELLESIP_EXPORT const char *belle_sip_multipart_body_handler_get_boundary(const belle_sip_multipart_body_handler_t *obj);
BELLESIP_EXPORT belle_sip_multipart_body_handler_t *belle_sip_multipart_body_handler_new(belle_sip_body_handler_progress_callback_t progress_cb, void *data, belle_sip_body_handler_t *first_part, const char *boundary);
BELLESIP_EXPORT belle_sip_multipart_body_handler_t *belle_sip_multipart_body_handler_new_from_buffer(const void *buffer, size_t bufsize, const char *boundary);
BELLESIP_EXPORT void belle_sip_multipart_body_handler_add_part(belle_sip_multipart_body_handler_t *obj, belle_sip_body_handler_t *part);
......
......@@ -827,6 +827,10 @@ static void belle_sip_multipart_body_handler_set_boundary(belle_sip_multipart_bo
}
}
const char *belle_sip_multipart_body_handler_get_boundary(const belle_sip_multipart_body_handler_t *obj) {
return obj->boundary;
}
belle_sip_multipart_body_handler_t *belle_sip_multipart_body_handler_new(belle_sip_body_handler_progress_callback_t progress_cb, void *data,
belle_sip_body_handler_t *first_part, const char *boundary){
belle_sip_multipart_body_handler_t *obj=belle_sip_object_new(belle_sip_multipart_body_handler_t);
......
......@@ -334,8 +334,7 @@ static void uncompress_body_if_required(belle_sip_message_t *msg) {
belle_sip_header_content_length_t *content_length = belle_sip_message_get_header_by_type(msg, belle_sip_header_content_length_t);
belle_sip_header_content_length_set_content_length(content_length, belle_sip_body_handler_get_size(BELLE_SIP_BODY_HANDLER(mbh)));
belle_sip_message_remove_header_from_ptr(msg, ceh);
if (content_type
&& (strcmp(belle_sip_header_content_type_get_type(content_type), "multipart") == 0)) {
if (content_type && (strcmp(belle_sip_header_content_type_get_type(content_type), "multipart") == 0)) {
const char *unparsed_value = belle_sip_header_get_unparsed_value(BELLE_SIP_HEADER(content_type));
const char *boundary = strstr(unparsed_value, ";boundary=");
if (boundary != NULL) boundary += 10;
......
......@@ -528,7 +528,7 @@ void belle_sip_message_set_body_handler(belle_sip_message_t *msg, belle_sip_body
}
const belle_sip_header_content_type_t *new_content_type_header = belle_sip_message_get_header_by_type(msg, belle_sip_header_content_type_t);
if (!new_content_type_header || !belle_sip_parameters_has_parameter(BELLE_SIP_PARAMETERS(new_content_type_header), "boundary")) {
belle_sip_parameters_set_parameter(BELLE_SIP_PARAMETERS(content_type), "boundary", BELLESIP_MULTIPART_BOUNDARY);
belle_sip_parameters_set_parameter(BELLE_SIP_PARAMETERS(content_type), "boundary", belle_sip_multipart_body_handler_get_boundary(multipart_body_handler));
belle_sip_message_add_header(BELLE_SIP_MESSAGE(msg), BELLE_SIP_HEADER(content_type));
}
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment