[Chapter 20] Media Types and Subtypes
Author: Stephen Spainhour and Valerie Quercia
Date: Fri Aug 29 18:16:44 1997

#

| Chapter 20 |

# 20. Media Types and Subtypes

Media types are used to communicate the format of the content in HTTP transactions. Clients use media types in their `Accept` headers to indicate what formats they prefer to receive data in. Servers use media types in their `Content-Type` headers to tell the client what format the accompanying entity is in--i.e., whether the enclosed text is HTML that needs to be formatted, GIF or JPEG to be rendered, or PDF format that requires opening an external viewer or using a plug-in.

See Chapter 19, HTTP Headers, for more information on the `Accept` and `Content-Type` headers.

Internet media types used by HTTP closely resemble MIME types. MIME (Multipurpose Internet Mail Extension) was designed as a method for sending attachments in mail over the Internet. Like MIME, media types follow the format type`/`subtype. Asterisks (`*`) represent a wildcard--for example, the following client header means that documents of all formats are accepted:

    Accept: */*

The following client header means that all `text` format types are accepted, regardless of the subtype:

    Accept: text/*

Servers and CGI programs are expected to examine the accept types reported by the `Accept` header and return data of an acceptable type when possible. Most servers determine the format of a document from its filename suffix--for example, a file ending with .html or .html is assumed to be HTML format, so the server will send the document with a `Content-Type` of `text/html`. When calling a CGI program, servers cannot know the format of the data being returned, so the CGI program is responsible for reporting the content type itself. For that reason, every CGI program needs to include a `Content-Type` header such as:

    Content-Type: text/html

The following table lists commonly-used media types along with the filename suffixes recognized by most servers. Most servers can be easily configured to recognize additional suffixes as well.

Type/Subtype | Usual extension
--- | ---
`application/activemessage` |
`application/andrew-inset` |
`application/applefile` |
`application/atomicmail` |
`application/cals-1840` |
`application/commonground` |
`application/cybercash` |
`application/dca-rft` |
`application/dec-dx` |
`application/eshop` |
`application/iges` |
`application/mac-binhex40` |
`application/macwriteii` |
`application/mathematica` |
`application/msword` |
`application/news-message-id` |
`application/news-transmission` |
`application/octet-stream` | bin
`application/oda` | oda
`application/pdf` | pdf
`application/postscript` | ai, eps, ps
`application/remote-printing` |
`application/riscos` |
`application/vnd.svd` |
`application/vnd.truedoc` |
`application/wita` |
`application/wordperfect5.1` |
`application/x-bcpio` | bcpio
`application/x-cpio` | cpio
`application/x-csh` | csh
`application/x-dvi` | dvi
`application/x-gtar` | gtar
`application/x-hdf` | hdf
`application/x-latex` | latex
`application/x-mif` | mif
`application/x-netcdf` | nc, cdf
`application/x-sh` | sh
`application/x-shar` | shar
`application/x-sv4cpio` | sv4cpio
`application/x-sv4crc` | sv4crc
`application/x-tar` | tar
`application/x-tcl` | tcl
`application/x-tex` | tex
`application/x-texinfo` | texinfo, texi
`application/x-troff-man` | man
`application/x-troff-me` | me
`application/x-troff-ms` | ms
`application/x-troff` | t, tr, roff
`application/x-ustar` | ustar
`application/x-wais-source` | src
`application/x400-bp` |
`application/zip` | zip
`audio/32kadpcm` `audio/basic` | au, snd
`audio/x-aiff` | aif, aiff, aifc
`audio/x-wav` | wav
`image/cgm` |
`image/g3fax` |
`image/gif` | gif
`image/ief` | ief
`image/jpeg` | jpeg, jpg, jpe
`image/naplps` |
`image/tiff` | tiff, tif
`image/vnd.dwg` |
`image/vnd.dxf` |
`image/vnd.svf` |
`image/x-cmu-raster` | ras
`image/x-portable-anymap` | rpnm
`image/x-portable-bitmap` | pbm
`image/x-portable-graymap` | pgm
`image/x-portable-pixmap` | ppm
`image/x-rgb` | rgb
`image/x-xbitmap` | xbm
`image/x-xpixmap` | xpm
`image/x-xwindowdump` | xwd
`message/external-body` |
`message/http` |
`message/news` |
`message/partial` |
`message/rfc822` |
`multipart/alternative` |
`multipart/appledouble` |
`multipart/digest` |
`multipart/form-data` |
`multipart/header-set` |
`multipart/mixed` |
`multipart/parallel` |
`multipart/related` |
`multipart/report` |
`multipart/voice-message` |
`text/enriched` |
`text/html` | html, htm
`text/plain` | txt
`text/richtext` | rtx
`text/sgml` |
`text/tab-separated-values` | tsv
`text/x-setext` | etx
`video/mpeg` | mpeg, mpg, mpe
`video/quicktime` | qt, mov
`video/vnd.vivo` |
`video/x-msvideo` | qvi
`video/x-sgi-movie` | movie

Entity Headers |  | JavaScript Quick Reference