From d0a8b3f15c440cbb5b3f88ef1c8d7af36cad454f Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Mon, 16 Apr 2018 15:54:07 +0200 Subject: [PATCH] Correctly set Content-Disposition header on multipart content. --- src/content/content-manager.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/content/content-manager.cpp b/src/content/content-manager.cpp index d4d07cf70..c82b4d432 100644 --- a/src/content/content-manager.cpp +++ b/src/content/content-manager.cpp @@ -23,6 +23,7 @@ #include "linphone/api/c-content.h" +#include "content-disposition.h" #include "content-manager.h" #include "content-type.h" #include "content/content.h" @@ -47,7 +48,10 @@ list ContentManager::multipartToContentList (const Content &content) { for (const belle_sip_list_t *parts = sal_body_handler_get_parts(sbh); parts; parts = parts->next) { SalBodyHandler *part = (SalBodyHandler *)parts->data; LinphoneContent *cContent = linphone_content_from_sal_body_handler(part); - contents.push_back(*L_GET_CPP_PTR_FROM_C_OBJECT(cContent)); + Content *cppContent = L_GET_CPP_PTR_FROM_C_OBJECT(cContent); + if (content.getContentDisposition().isValid()) + cppContent->setContentDisposition(content.getContentDisposition()); + contents.push_back(*cppContent); linphone_content_unref(cContent); } @@ -61,7 +65,12 @@ Content ContentManager::contentListToMultipart (const list &contents) ); mpbh = (belle_sip_multipart_body_handler_t *)belle_sip_object_ref(mpbh); + ContentDisposition disposition; for (Content *content : contents) { + // Is this content-disposition stuff generic or only valid for notification content-disposition? + if (content->getContentDisposition().isValid()) + disposition = content->getContentDisposition(); + LinphoneContent *cContent = L_GET_C_BACK_PTR(content); SalBodyHandler *sbh = sal_body_handler_from_content(cContent); belle_sip_multipart_body_handler_add_part(mpbh, BELLE_SIP_BODY_HANDLER(sbh)); @@ -76,6 +85,8 @@ Content ContentManager::contentListToMultipart (const list &contents) belle_sip_object_unref(mpbh); Content content = *L_GET_CPP_PTR_FROM_C_OBJECT(cContent); + if (disposition.isValid()) + content.setContentDisposition(disposition); linphone_content_unref(cContent); return content; }