// Construct a MimeBodyPart from an HttpBody and a list of parameters. MimeBodyPart::MimeBodyPart(const HttpBody& httpBody, //< Provides the bytes of the body. const UtlDList& parameters //< Provides the parameters. ) : HttpBody(httpBody), mpParentBody(NULL), mParentBodyRawStartIndex(-1), mRawBodyLength(-1), mParentBodyStartIndex(-1), mBodyLength(-1) { // Copy the parameters to mNameValues. UtlDListIterator iterator(parameters); NameValuePair* nvp; while((nvp = (NameValuePair*) iterator())) { mNameValues.append(new NameValuePair(nvp->data(), nvp->getValue())); } // Add the Content-Type parameter, taken from the HttpBody. mNameValues.append(new NameValuePair(HTTP_CONTENT_TYPE_FIELD, httpBody.getContentType())); // Add the Content-Transfer-Encoding parameter. mNameValues.append(new NameValuePair(HTTP_CONTENT_TRANSFER_ENCODING_FIELD, HTTP_CONTENT_TRANSFER_ENCODING_BINARY)); // Members that reference the parent will be corrected later. }
UtlBoolean SipSubscribeServerEventHandler::getNotifyContent(const UtlString& resourceId, const UtlString& eventTypeKey, const UtlString& eventType, SipPublishContentMgr& contentMgr, const char* acceptHeaderValue, SipMessage& notifyRequest, int& version) { UtlBoolean gotBody = FALSE; // Default behavior is to just go get the content from // the content manager and attach it to the notify HttpBody* messageBody = NULL; UtlBoolean isDefaultEventContent; gotBody = contentMgr.getContent(resourceId, eventTypeKey, eventType, acceptHeaderValue, messageBody, version, isDefaultEventContent); // The body will be freed with the NOTIFY message. if(messageBody) { const char* contentTypePtr = messageBody->getContentType(); UtlString contentType; if(contentTypePtr) { contentType = contentTypePtr; } else { OsSysLog::add(FAC_SIP, PRI_ERR, "SipSubscribeServerEventHandler::getNotifyContent body published for resourceId: '%s' eventTypeKey: '%s' with no content type", resourceId.data() ? resourceId.data() : "<null>", eventTypeKey.data() ? eventTypeKey.data() : "<null>"); contentType = "text/unknown"; } notifyRequest.setContentType(contentType); notifyRequest.setBody(messageBody); UtlString request; ssize_t requestLength; notifyRequest.getBytes(&request, &requestLength); OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipSubscribeServerEventHandler::getNotifyContent resourceId '%s', eventTypeKey '%s' contentType '%s' NOTIFY message length = %zu, message = '%s'", resourceId.data(), eventTypeKey.data(), contentType.data(), requestLength, request.data()); } return(gotBody); }