MIME Content-Type Header and Discrete Media: Types, Subtypes and Parameters
(Page 1 of 5)
MIME transforms TCP/IP e-mail from the drab, text-only world of RFC 822, to a rich communication method that can carry many types of data. It accomplishes this by using special techniques to encode various kinds of information into ASCII text form, such as graphical images, sound files, video clips, application programs, compressed data files, and many others. We commonly refer to these as different types of media, and MIME uses the same term to describe them.
Since MIME supports so many kinds of media, it is necessary that each message contain information that describes what it contains, to permit accurate decoding of message contents. This is the function of the important MIME Content-Type header.
The syntax of the header is as follows:
Content-Type: <type>/<subtype> [; parameter1 ; parameter2 .. ; parameterN ]
The purpose of these different elements is to describe the media in the MIME entity in a way that proceeds from the general to the specific. The first element, <type>, is called the top-level media type and describes the overall form of the data. For example, it indicates if the MIME entity contains text, an image, audio and so forth. The second element, <subtype>, provides specific information about the form or format of the data. For example, a JPEG image and a GIF image are both images, but they are in a different format. Both <type> and <subtype> are mandatory in the Content-Type header.
Following these elements may appear one or more parameters, which are usually optional but may be required for some media types. These provide still more detailed specification of the nature of the data, when it is required. Each parameter is preceded by a semi-colon and is expressed as an attribute/value pair, separated by an = sign, like this:
One example of how parameters may be used is in specifying the character set in a text message. The representation of regular RFC 822 ASCII text is as follows:
Content-type: text/plain; charset=us-ascii
The top-level media type is text, and the subtype is plain, so this indicates a plain text message. The parameter charset specifies that the message uses the US ASCII character set. Another common use for parameters is to specify the name of an attached file, like this:
Content-type: image/jpeg; name=ryanpicture.jpg
Home - Table Of Contents - Contact Us
The TCP/IP Guide (http://www.TCPIPGuide.com)
Version 3.0 - Version Date: September 20, 2005
© Copyright 2001-2005 Charles M. Kozierok. All Rights Reserved.
Not responsible for any loss resulting from the use of this site.