diff --git a/src/chat/chat-message/chat-message.cpp b/src/chat/chat-message/chat-message.cpp index 26232bbeb..ddfd018a6 100644 --- a/src/chat/chat-message/chat-message.cpp +++ b/src/chat/chat-message/chat-message.cpp @@ -582,7 +582,7 @@ LinphoneReason ChatMessagePrivate::receive () { foundSupportContentType = true; break; } else - lError() << "Unsupported content-type: " << c->getContentType().asString(); + lError() << "Unsupported content-type: " << c->getContentType(); } if (!foundSupportContentType) { diff --git a/src/chat/modifier/cpim-chat-message-modifier.cpp b/src/chat/modifier/cpim-chat-message-modifier.cpp index 8958c0f82..03c35fed0 100644 --- a/src/chat/modifier/cpim-chat-message-modifier.cpp +++ b/src/chat/modifier/cpim-chat-message-modifier.cpp @@ -98,7 +98,7 @@ ChatMessageModifier::Result CpimChatMessageModifier::decode (const shared_ptrgetContents().front(); if (content->getContentType() != ContentType::Cpim) { - lError() << "[CPIM] Message is not CPIM but " << content->getContentType().asString(); + lError() << "[CPIM] Message is not CPIM but " << content->getContentType(); return ChatMessageModifier::Result::Skipped; } diff --git a/src/content/content-type.cpp b/src/content/content-type.cpp index e5d58c7a7..3d6b4689f 100644 --- a/src/content/content-type.cpp +++ b/src/content/content-type.cpp @@ -55,7 +55,6 @@ const ContentType ContentType::Sdp("application/sdp"); ContentType::ContentType (const string &contentType) : Header(*new ContentTypePrivate) { L_D(); - setName("Content-Type"); size_t pos = contentType.find('/'); size_t posParam = contentType.find(";"); size_t end = contentType.length(); @@ -89,7 +88,6 @@ ContentType::ContentType (const string &contentType) : Header(*new ContentTypePr ContentType::ContentType (const string &type, const string &subType) : Header(*new ContentTypePrivate) { L_D(); - setName("Content-Type"); if (setType(type) && !setSubType(subType)) d->type.clear(); } @@ -101,7 +99,6 @@ ContentType::ContentType ( ) : Header(*new ContentTypePrivate) { L_D(); - setName("Content-Type"); if (setType(type) && !setSubType(subType)) d->type.clear(); addParameter(parameter); @@ -114,7 +111,6 @@ ContentType::ContentType ( ) : Header(*new ContentTypePrivate) { L_D(); - setName("Content-Type"); if (setType(type) && !setSubType(subType)) d->type.clear(); addParameters(parameters); @@ -124,7 +120,6 @@ ContentType::ContentType (const ContentType &other) : ContentType(other.getType( ContentType &ContentType::operator= (const ContentType &other) { if (this != &other) { - setName("Content-Type"); setType(other.getType()); setSubType(other.getSubType()); cleanParameters(); @@ -183,23 +178,6 @@ bool ContentType::isValid () const { return !d->type.empty() && !d->subType.empty(); } -string ContentType::asString () const { - L_D(); - if (isValid()) { - string asString = d->type + "/" + d->subType; - for (const auto ¶m : getParameters()) { - asString += param.asString(); - } - return asString; - } - return ""; -} - -ostream &operator<<(ostream& stream, const ContentType& contentType) { - stream << contentType.asString(); - return stream; -} - bool ContentType::isMultipart() const { return getType() == "multipart"; } diff --git a/src/content/content-type.h b/src/content/content-type.h index 10f895e4d..c9aa7af77 100644 --- a/src/content/content-type.h +++ b/src/content/content-type.h @@ -58,9 +58,6 @@ public: const std::string &getSubType () const; bool setSubType (const std::string &subType); - std::string asString () const; - friend std::ostream &operator<<(std::ostream&, const ContentType&); - bool isMultipart() const; static bool isFile (const ContentType &contentType); diff --git a/src/content/header/header.cpp b/src/content/header/header.cpp index 14ce99f85..92920e024 100644 --- a/src/content/header/header.cpp +++ b/src/content/header/header.cpp @@ -17,6 +17,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include + #include "linphone/utils/utils.h" #include "linphone/utils/algorithm.h" @@ -141,11 +143,15 @@ const HeaderParam &Header::getParameter (const std::string ¶mName) const { } string Header::asString () const { - string asString = getName() + ":" + getValue(); + stringstream asString; + if (!getName().empty()) { + asString << getName() << ":"; + } + asString << getValue(); for (const auto ¶m : getParameters()) { - asString += param.asString(); + asString << param.asString(); } - return asString; + return asString.str(); } ostream &operator<<(ostream& stream, const Header& header) {