Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Internet Protocols Module User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

10.2 Constructing MIME Part Bodies

The body of a MIME part is the actual content. The MIME specification places few requirements on the part body. This section briefly discusses these requirements.

10.2.1 Canonical Form

The MIME specification requires that every simple content type define a standard format, called the canonical form. The MIME specification recommends that data be converted to canonical form before the data is encoded or inserted into a message. The specification describes the canonical form of a few media types and outlines a process for registering new types. The Internet Assigned Numbers Authority publishes a list of assigned media types and maintains a repository of the data format descriptions for those types.

For text, the canonical form uses a carriage return (ASCII 13) followed by a line feed (ASCII 10) to indicate a line break. Typically, an application converts text to canonical form before including the text in a message.

For most other content types, the canonical form is identical to the normal format of the file. A good working strategy is to always convert text to canonical form and to assume that other data does not require conversion. We use this strategy in this manual. Be aware, though, that some file formats might have a canonical form different than the normal format of the data.

There is no canonical form for multipart content types. Instead, each part contained in a multipart body must be in canonical form.

10.2.2 Multipart Bodies

A MIME part body may contain nested MIME parts. In this case, each nested part contains its own set of headers and its own part body. The top-level part has the media type multipart.

The MIME specification defines four multipart subtypes. The MIME package also supports an additional multipart subtype, the multipart/related content type described in RFC 2387. All multipart types require that the header value contain a boundary parameter. The value of the boundary parameter delimits the parts of the message. For example, the message snippet below contains two parts delimited by __the_boundary__:

Since the MIME format uses the value of the boundary parameter to tell where parts begin and end, it's important that the value does not occur in the content of any message part. This restriction includes parts which are themselves multiparts. In other words, if a message contains more than one multipart, each multipart in the message must use a different boundary. Otherwise, a recipient has no way to reconstruct the message accurately.


An RWMimeMultipart must not contain itself, either directly or indirectly. A part that contains itself cannot be represented as a string.

The RWMimeUtils class provides a static getUniqueBoundary() function that generates strings unlikely to occur in message content. See the SourcePro C++ API Reference Guide for details.

The relationship between the parts of a multipart media type determines the subtype. The table below describe common multipart types:

Table 2: MIME multipart subtypes

Multipart subtype Relationship of parts
mixed Parts are unrelated documents (for example, email attachments).
related Parts are components of a single document (for example, an HTML page and the images in that page).
parallel Parts should be displayed simultaneously (for example, audio and video).
alternative Parts contain the same content in alternative formats (for example, an HTML page and a plain text equivalent).
digest Parts are RFC 822 (email) messages.

A Content-Type of multipart/mixed is typically used for email attachments, and is therefore the most common multipart type. A default-constructed R-WMimeMultipartType object represents a multipart/mixed header value.

The value of a multipart/related Content-Type contains a boundary parameter, a required type parameter and two optional parameters, start and start-info. The type parameter matches the Content-Type of the part to be processed first. By default, an application begins processing a multipart/related body at the first contained part. If the start parameter is present, an application begins processing a multipart/related body at the part that contains a Content-ID value matching the value of the start parameter. If the start-info parameter is present, the value of the parameter provides information for the processing application. The MIME package provides class RWMimeMultipartRelatedType for convenience in working with the additional parameters in a multipart/related content type.



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.