Each MIME media type consists of a type, a subtype, and a list of optional parameters. The type and subtype are separated by a slash, and the optional parameters begin with a semicolon, if they are present. In HTTP, MIME media types are widely used in Content-Type and Accept headers. Here are a few examples:
Content-Type: video/quicktime
Content-Type: text/html; charset="iso-8859-6"
Content-Type: multipart/mixed; boundary=gc0p4Jq0M2Yt08j34c0p
Accept: image/gif
MIME types can directly describe the object type, or they can describe collections or packages of other object types. If a MIME type describes an object type directly, it is a discrete type . These include text files, videos , and application-specific file formats.
If a MIME type describes a collection or encapsulation of other content, the MIME type is called a composite type . A composite type describes the format of the enclosing package. When the enclosing package is opened, each enclosed object will have its own type.
Multipart media types are composite types. A multipart object consists of multiple component types. Here's an example of multipart/mixed content, where each component has its own MIME type:
Content-Type: multipart/mixed ; boundary=unique-boundary-1
--unique-boundary-1
Content-type: text/plain ; charset=US-ASCII
Hi there, I'm some boring ASCII text...
--unique-boundary-1
Content-Type: multipart/parallel ; boundary=unique-boundary-2
--unique-boundary-2
Content-Type: audio/basic
... 8000 Hz single-channel mu-law-format
audio data goes here ...
--unique-boundary-2
Content-Type: image/jpeg
... image data goes here ...
--unique-boundary-2--
--unique-boundary-1
Content-type: text/enriched
This is <bold><italic>enriched.</italic></bold>
<smaller>as defined in RFC 1896</smaller>
Isn't it <bigger><bigger>cool?</bigger></bigger>
--unique-boundary-1
Content-Type: message/rfc822
From: (mailbox in US-ASCII)
To: (address in US-ASCII)
Subject: (subject in US-ASCII)
Content-Type: Text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: Quoted-printable
... Additional text in ISO-8859-1 goes here ...
--unique-boundary-1--
As we stated earlier, MIME types consist of a primary type, a subtype, and an optional list of parameters.
The primary type can be a predefined type, an IETF-defined extension token, or an experimental token (beginning with "x-"). Some common primary types are described in Table D-1 .
Table D-1. Common primary MIME types | |
Type | Description |
application | Application-specific content format (discrete type) |
audio | Audio format (discrete type) |
chemical | Chemical data set (discrete IETF extension type) |
image | Image format (discrete type) |
message | Message format (composite type) |
model | 3-D model format (discrete IETF extension type) |
multipart | Collection of multiple objects (composite type) |
text | Text format (discrete type) |
video | Video movie format (discrete type) |
Subtypes can be primary types (as in "text/text"), IANA-registered subtypes , or experimental extension tokens (beginning with "x-").
Types and subtypes are made up of a subset of US-ASCII characters. Spaces and certain reserved grouping and punctuation characters, called "tspecials," are control characters and are forbidden from type and subtype names .
The grammar from RFC 2046 is shown below:
TYPE := "application" "audio" "image" "message" "multipart"
"text" "video" IETF-TOKEN X-TOKEN
SUBTYPE := IANA-SUBTOKEN IETF-TOKEN X-TOKEN
IETF-TOKEN := <extension token with RFC and registered with IANA>
IANA-SUBTOKEN := <extension token registered with IANA>
X-TOKEN := <"X-" or "x-" prefix, followed by any token>
PARAMETER := TOKEN "=" VALUE
VALUE := TOKEN / QUOTED-STRING
TOKEN := 1*<any (US-ASCII) CHAR except SPACE, CTLs, or TSPECIALS>
TSPECIALS := "(" ")" "<" ">" "@"
"," ";" ":" "\" <">
"/" "[" "]" "?" "="