HP-UX C SIP Stack Programmer's Guide (Novembery 2007)
Working with SIP Messages 183
Working With Multipart MIME
/*Constructs the new body part within the given body object.*/
rv = RvSipBodyPartConstructInBody(hBody, RV_FALSE, &hBodyPart);
if (RV_OK != rv)
{
printf("Failed to construct body part");
return;
}
/*Parses the body part string.*/
rv = RvSipBodyPartParse(hBodyPart, strBodyPart2, strlen(strBodyPart2));
if (RV_OK != rv)
{
printf("Failed to parse body part");
return;
}
}
/*=========================================================================================*/
ENCODING A
M
ULTIPART BODY
After building a Body object from multiple Body Part objects, you can encode
the Body into a textual Body using the function, RvSipBodyEncode().
In order to encode Body of type Multipart, the Body object should contain a
multipart Content-Type with a valid boundary parameter. Note the following:
If the Body object you wish to encode does not contain a
Content-Type header, the SIP Stack will add a Content-Type
header and will initialize it to multipart/mixed media.
If the Content-Type header does not contain a boundary
parameter the SIP Stack will generate a unique boundary
according to the rules defined in RFC 2046 and will set it to the
Content-Type header.
BODY STRING A Body object can be represented as a string or as a list of Body Parts
A multipart Body is represented as a string only when the Body object is not
parsed, such as in the messageRecvd callback. You can get the Body string
using the RvSipBodyGetBodyStrLength() and RvSipBodyGetBodyStr()
functions, as shown in the following code. To set a Body string to a Body object,
use the function, RvSipBodySetBodyStr().
After you parse a multipart Body object, or after you set a Body Part to the Body
object, the Body string can no longer be retrieved. A Body with a list of Body
Parts does not contain a string. In this case when calling the function,
RvSipBodyGetBodyStrLength(), the returned length will be 0.