Multipart SIP body looks like this: --terminator Content-Type: ... eol body eol --terminator Content-Type: ... eol body eol --terminator--
| 357 | // eol |
| 358 | // --terminator-- |
| 359 | void 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 | |
| 390 | string SipMessage::smGetMessageBody() const |
| 391 | { |
no test coverage detected