Commit bac60c86 authored by johan's avatar johan
Browse files

Multipart Message: let bellesip take care of message header

parent 9e55c638
......@@ -36,8 +36,6 @@
static void _linphone_chat_room_send_message(LinphoneChatRoom *cr, LinphoneChatMessage* msg);
#define MULTIPART_BOUNDARY "---------------------------14737809831466499882746641449"
const char *multipart_boundary=MULTIPART_BOUNDARY;
static void process_io_error_upload(void *data, const belle_sip_io_error_event_t *event){
LinphoneChatMessage* msg=(LinphoneChatMessage *)data;
......@@ -128,7 +126,6 @@ static void linphone_chat_message_process_response_from_post_file(void *data, co
belle_http_request_t *req;
belle_sip_multipart_body_handler_t *bh;
char* ua;
char *content_type;
char *first_part_header;
belle_sip_user_body_handler_t *first_part_bh;
......@@ -144,19 +141,14 @@ static void linphone_chat_message_process_response_from_post_file(void *data, co
/* insert it in a multipart body handler which will manage the boundaries of multipart message */
bh=belle_sip_multipart_body_handler_new(linphone_chat_message_file_transfer_on_progress, msg, (belle_sip_body_handler_t *)first_part_bh);
/* create the http request: do not include the message header at this point, it is done by bellesip when setting the multipart body handler in the message */
ua = ms_strdup_printf("%s/%s", linphone_core_get_user_agent_name(), linphone_core_get_user_agent_version());
content_type=belle_sip_strdup_printf("multipart/form-data; boundary=%s",multipart_boundary);
uri=belle_generic_uri_parse(linphone_core_get_file_transfer_server(msg->chat_room->lc));
req=belle_http_request_create("POST",
uri,
belle_sip_header_create("User-Agent",ua),
belle_sip_header_create("Content-type",content_type),
NULL);
ms_free(ua);
belle_sip_free(content_type);
belle_sip_message_set_body_handler(BELLE_SIP_MESSAGE(req),BELLE_SIP_BODY_HANDLER(bh));
cbs.process_response=linphone_chat_message_process_response_from_post_file;
cbs.process_io_error=process_io_error_upload;
......
......@@ -276,8 +276,6 @@ static void process_auth_requested_upload_log_collection(void *data, belle_sip_a
delete_log_collection_upload_file();
}
extern const char *multipart_boundary;
/**
* Callback called when posting a log collection file to server (following rcs5.1 recommendation)
*
......@@ -341,7 +339,6 @@ static void process_response_from_post_file_log_collection(void *data, const bel
belle_http_request_t *req;
belle_sip_multipart_body_handler_t *bh;
char* ua;
char *content_type;
char *first_part_header;
belle_sip_user_body_handler_t *first_part_bh;
......@@ -359,11 +356,9 @@ static void process_response_from_post_file_log_collection(void *data, const bel
/* Insert it in a multipart body handler which will manage the boundaries of multipart message */
bh = belle_sip_multipart_body_handler_new(log_collection_upload_on_progress, core, (belle_sip_body_handler_t *)first_part_bh);
ua = ms_strdup_printf("%s/%s", linphone_core_get_user_agent_name(), linphone_core_get_user_agent_version());
content_type = belle_sip_strdup_printf("multipart/form-data; boundary=%s", multipart_boundary);
uri = belle_generic_uri_parse(linphone_core_get_log_collection_upload_server_url(core));
req = belle_http_request_create("POST", uri, belle_sip_header_create("User-Agent", ua), belle_sip_header_create("Content-type", content_type), NULL);
req = belle_http_request_create("POST", uri, belle_sip_header_create("User-Agent", ua), NULL);
ms_free(ua);
belle_sip_free(content_type);
belle_sip_message_set_body_handler(BELLE_SIP_MESSAGE(req), BELLE_SIP_BODY_HANDLER(bh));
cbs.process_response = process_response_from_post_file_log_collection;
cbs.process_io_error = process_io_error_upload_log_collection;
......
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