MCPcopy Create free account
hub / github.com/RangeNetworks/openbts / smAddBody

Method smAddBody

SIP/SIPMessage.cpp:359–388  ·  view source on GitHub ↗

Multipart SIP body looks like this: --terminator Content-Type: ... eol body eol --terminator Content-Type: ... eol body eol --terminator--

Source from the content-addressed store, hash-verified

357// eol
358// --terminator--
359void SipMessage::smAddBody(string contentType, string body1)
360{
361 static string separator("--zzyzx\r\n");
362 static string terminator("--zzyzx--\r\n");
363 static string eol("\r\n");
364 if (msmBody.empty()) {
365 msmContentType = contentType;
366 msmBody = body1;
367 } else {
368 // TODO: TEST THIS!
369 string ctline = format("Content-Type: %s\r\n",contentType.c_str());
370 string newbody;
371 if (msmContentType.substr(0,strlen("multipart")) != "multipart") {
372 // We are switching to multipart now.
373 // Move the original content-type/body into the multipart body.
374 newbody = separator + ctline + eol + msmBody + eol;
375 msmContentType = "multipart/mixed;boundary=zzyzx";
376 } else {
377 newbody = msmBody;
378 // Chop off the previous terminator.
379 newbody = newbody.substr(0,newbody.size() - terminator.size());
380 }
381 // Add the new contentType and body.
382 newbody.reserve(msmBody.size() + body1.size() + 100);
383 // This requires C++11:
384 // newbody.append(separator, ctline, eol, body1, eol, terminator);
385 newbody.append(separator + ctline + eol + body1 + eol + terminator);
386 msmBody = newbody;
387 }
388}
389
390string SipMessage::smGetMessageBody() const
391{

Callers 7

MOUssdSendINVITEMethod · 0.80
MOCSendINVITEMethod · 0.80
MOSMSSendMESSAGEMethod · 0.80
MTCSendOKMethod · 0.80
SipDtmfTUMethod · 0.80
newSipDialogHandoverMethod · 0.80

Calls 2

sizeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected