(w3.info)Adding MIME types based on file extensions

Next: Mapping gopher types to MIME types Prev: MIME Support Up: MIME Support

Adding MIME types based on file extensions

   For some protocols however, it is still necessary to guess the
content of a file based on the file extension.  This type of guess-work
should only be needed when accessing files via FTP, local file access,
or old HTTP/0.9 servers.

   Instead of specifying how to view things twice, once based on
content-type and once based on the file extension, it is easier to map
file extensions to MIME content-types.  The variable that controls this
is `w3-mime-extensions'.

   This variable is an assoc list of file extensions and the
corresponding MIME content-type.  A sample entry looks like: `(".movie"
. "video/x-sgi-movie")' This makes all files that end in `.movie'
(`foo.movie' and `bar.movie') be interpreted as SGI animation files.
If a content-type is defined for the document, then this is
over-ridden.  Regular expressions can NOT be used.

   Both Mosaic and the NCSA HTTP daemon rely on a separate file for
mapping file extensions to MIME types.  Instead of having the users of
W3 duplicate this in lisp, this file can be parsed using the
`w3-parse-mime-types' function.  This function is called each time w3
is loaded, and tries to parse the file `~/.mime-types' if it exists.
This format of this file is as follows.

   Each line contains information for one http type.  These types
resemble MIME types.  If you plan to add new ones, you should use
subtypes beginning with x-, such as application/x-myprogram.  Lines
beginning with # are comment lines, and suitably ignored.  Each line
consists of:

   type/subtype ext1 ext2 ...  extN

   type/subtype is the MIME-like type of the document. ext* is any
number of space-separated filename extensions which correspond to the
MIME type.

automatically generated by info2www