The Content-Type Header
The Content-Type header declares the original file format of the part body. In Figure 32, the Content-Type header contains the value text/plain and one parameter, charset=us-ascii.
A Content-Type header contains two values separated by a slash. These values are the media type and subtype of the Content-Type. In Figure 32, the media type is text and the subtype is plain.
The media type specifies the kind of content in broad terms, while the subtype is more specific. For example, the media type text has common subtypes such as plain, html, and xml. In all three cases, the basic format of the document is text, and the document can be considered text for many purposes, such as deciding whether the document can be usefully opened within a text editor. The subtype provides more detailed information about the content. Although an HTML document can be displayed as plain text, rendering the document in a browser or opening the document in an HTML editor may be more useful.
The two-part value gives applications a way to determine the preferred handling of a document. If the application recognizes both the media type and subtype, the application can handle the content in exactly the way the sender intended. If the application only recognizes the media type, the application can still provide a reasonable fallback.
Depending on the media type or subtype, a Content-Type may require a parameter. For example, MIME allows text content types to include a parameter specifying the character set. The Content-Type header in Figure 32 contains the parameter charset=us-ascii.
MIME defines five media types for discrete content: text, image, audio, video, and application. The message media type is defined for MIME parts that contain complete messages as content, such as an email digest.
For messages containing more than one MIME part, the format defines a media type of multipart. The requirements of the multipart content type are intimately connected with the body of the message. Multipart Bodies discusses -multipart message bodies and content types.
A Content-Type header is optional. The MIME specification defines a part without a Content-Type header as text/plain; charset=us-ascii.
RFC 2045 defines the Content-Type header in section 5 (p. 10). RFC 2046 discusses specific Content-Type values.