844N/AXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 0N/A This file is generated from xml source: DO NOT EDIT 0N/AXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 0N/A--><
title>mod_mime_magic - Apache HTTP Server</
title><
link href="/style/manual.css" type="text/css" rel="stylesheet"/></
head><
body><
blockquote><
div align="center"><
img alt="[APACHE DOCUMENTATION]" src="/images/sub.gif"/><
h3>Apache HTTP Server Version 2.0</
h3></
div><
h1 align="center">Apache Module mod_mime_magic</
h1><
table cellspacing="1" cellpadding="0" bgcolor="#cccccc"><
tr><
td><
table bgcolor="#ffffff"><
tr><
td valign="top"><
span class="help">Description:</
span></
td><
td>Determines the MIME type of a file
0N/A by looking at a few bytes of its contents</
td></
tr><
tr><
td><
a href="module-dict.html#Status" class="help">Status:</
a></
td><
td>Extension</
td></
tr><
tr><
td><
a href="module-dict.html#ModuleIdentifier" class="help">Module Identifier:</
a></
td><
td>mime_magic_module</
td></
tr></
table></
td></
tr></
table><
h2>Summary</
h2>
0N/A <
p>This module determines the MIME type of files in the same
0N/A way the Unix file(1) command works: it looks at the first few
0N/A bytes of the file. It is intended as a "second line of defense"
0N/A resolve. To assure that mod_mime gets first try at determining
0N/A a file's MIME type, be sure to list mod_mime_magic
0N/A <
strong>before</
strong> mod_mime in the configuration.</
p>
0N/A <
p>This module is derived from a free version of the
0N/A <
code>file(1)</
code> command for Unix, which uses "magic
0N/A numbers" and other hints from a file's contents to figure out
0N/A what the contents are. This module is active only if the magic
0N/A file is specified by the <
a href="#mimemagicfile" class="directive"><
code class="directive">MimeMagicFile</
code></
a> directive.</
p>
0N/A<
h2>Directives</
h2><
ul><
li><
a href="#mimemagicfile">MimeMagicFile</
a></
li></
ul><
h2>Format of the Magic File</
h2>
0N/A <
p>The contents of the file are plain ASCII text in 4-5
0N/A columns. Blank lines are allowed but ignored. Commented lines
0N/A use a hash mark "#". The remaining lines are parsed for the
0N/A following columns:</
p>
0N/A <
th>Description</
th>
0N/A <
td>byte number to begin checking from<
br>
0N/A ">" indicates a dependency upon the previous non-">"
0N/A type of data to match
0N/A <
td>single character</
td>
0N/A <
td>machine-order 16-bit integer</
td>
0N/A <
td>machine-order 32-bit integer</
td>
0N/A <
td>arbitrary-length string</
td>
0N/A <
td>long integer date (seconds since Unix
413N/A <
td>big-endian 16-bit integer</
td>
0N/A <
td>big-endian 32-bit integer</
td>
0N/A <
td>big-endian 32-bit integer date</
td>
0N/A <
td>little-endian 16-bit integer</
td>
413N/A <
td>little-endian 32-bit integer</
td>
0N/A <
td>little-endian 32-bit integer date</
td>
0N/A <
td>contents of data to match</
td>
0N/A <
td>MIME type if matched</
td>
0N/A <
td>MIME encoding if matched (optional)</
td>
0N/A <
p>For example, the following magic file lines would recognize
0N/A some audio formats.</
p>
0N/A<
blockquote><
table cellpadding="10"><
tr><
td bgcolor="#eeeeee"><
code>
0N/A</
code></
td></
tr></
table></
blockquote>
0N/A <
p>Or these would recognize the difference between "*.doc" files
0N/A containing Microsoft Word or FrameMaker documents. (These are
0N/A incompatible file formats which use the same file suffix.)</
p>
0N/A<
blockquote><
table cellpadding="10"><
tr><
td bgcolor="#eeeeee"><
code>
0N/A</
code></
td></
tr></
table></
blockquote>
0N/A <
p>An optional MIME encoding can be included as a fifth column.
0N/A For example, this can recognize gzipped files and set the
0N/A encoding for them.</
p>
0N/A<
blockquote><
table cellpadding="10"><
tr><
td bgcolor="#eeeeee"><
code>
0N/A</
code></
td></
tr></
table></
blockquote>
0N/A<
h2>Performance Issues</
h2>
0N/A <
p>This module is not for every system. If your system is barely
0N/A keeping up with its load or if you're performing a web server
0N/A benchmark, you may not want to enable this because the
0N/A processing is not free.</
p>
0N/A <
p>However, an effort was made to improve the performance of
0N/A the original file(1) code to make it fit in a busy web server.
0N/A It was designed for a server where there are thousands of users
0N/A who publish their own documents. This is probably very common
0N/A on intranets. Many times, it's helpful if the server can make
0N/A more intelligent decisions about a file's contents than the
0N/A file name allows
...even if just to reduce the "why doesn't my
0N/A page work" calls when users improperly name their own files.
0N/A You have to decide if the extra work suits your
0N/A <
p>When compiling an Apache server, this module should be at or
0N/A near the top of the list of modules in the Configuration file.
0N/A The modules are listed in increasing priority so that will mean
0N/A this one is used only as a last resort, just like it was
0N/A<
h2><
a name="notes">Notes</
a></
h2>
0N/A <
p>The following notes apply to the mod_mime_magic module and are
0N/A included here for compliance with contributors' copyright
0N/A restrictions that require their acknowledgment. </
p>
0N/A * mod_mime_magic: MIME type lookup via file magic numbers
0N/A * Copyright (c) 1996-1997 Cisco Systems, Inc.
0N/A * This software was submitted by Cisco Systems to the Apache Group in July
0N/A * 1997. Future revisions and derivatives of this source code must
0N/A * acknowledge Cisco Systems as the original contributor of this module.
0N/A * All other licensing and usage conditions are those of the Apache Group.
0N/A * Some of this code is derived from the free version of the file command
0N/A * is included below as required.
0N/A * ---------------------------------------------------------------------------
0N/A * - Copyright (c) Ian F. Darwin, 1987. Written by Ian F. Darwin.
0N/A * This software is not subject to any license of the American Telephone and
0N/A * Telegraph Company or of the Regents of the University of California.
0N/A * Permission is granted to anyone to use this software for any purpose on any
0N/A * computer system, and to alter it and redistribute it freely, subject to
0N/A * the following restrictions:
0N/A * 1. The author is not responsible for the consequences of use of this
0N/A * software, no matter how awful, even if they arise from flaws in it.
0N/A * 2. The origin of this software must not be misrepresented, either by
0N/A * explicit claim or by omission. Since few users ever read sources, credits
0N/A * must appear in the documentation.
0N/A * 3. Altered versions must be plainly marked as such, and must not be
0N/A * misrepresented as being the original software. Since few users ever read
0N/A * sources, credits must appear in the documentation.
0N/A * 4. This notice may not be removed or altered.
0N/A * -------------------------------------------------------------------------
0N/A * For compliance with Mr Darwin's terms: this has been very significantly
0N/A * modified from the free "file" command.
0N/A * - all-in-one file for compilation convenience when moving from one
0N/A * version of Apache to the next.
0N/A * - Memory allocation is done through the Apache API's pool structure.
0N/A * - All functions have had necessary Apache API request or server
0N/A * structures passed to them where necessary to call other Apache API
0N/A * routines. (<
em>
i.e.</
em>, usually for logging, files, or memory allocation in
0N/A * itself or a called function.)
0N/A * - struct magic has been converted from an array to a single-ended linked
0N/A * list because it only grows one record at a time, it's only accessed
0N/A * sequentially, and the Apache API has no equivalent of realloc().
0N/A * - Functions have been changed to get their parameters from the server
0N/A * configuration instead of globals. (It should be reentrant now but has
0N/A * not been tested in a threaded environment.)
0N/A * - Places where it used to print results to stdout now saves them in a
0N/A * list where they're used to set the MIME type in the Apache request
0N/A * - Command-line flags have been removed since they will never be used here.
0N/A<
hr/><
h2><
a name="MimeMagicFile">MimeMagicFile</
a> <
a name="mimemagicfile">Directive</
a></
h2><
table cellpadding="1" cellspacing="0" border="0" bgcolor="#cccccc"><
tr><
td><
table bgcolor="#ffffff"><
tr><
td><
strong>Description: </
strong></
td><
td>Enable MIME-type determination based on file contents
0N/Ausing the specified magic file</
td></
tr><
tr><
td><
a href="directive-dict.html#Syntax" class="help">Syntax:</
a></
td><
td>MimeMagicFile <
em>file-path</
em></
td></
tr><
tr><
td><
a href="directive-dict.html#Context" class="help">Context:</
a></
td><
td>server config, virtual host</
td></
tr><
tr><
td><
a href="directive-dict.html#Status" class="help">Status:</
a></
td><
td>Extension</
td></
tr><
tr><
td><
a href="directive-dict.html#Module" class="help">Module:</
a></
td><
td>mod_mime_magic</
td></
tr></
table></
td></
tr></
table>
0N/A <
p>The <
code class="directive">MimeMagicFile</
code> directive can be used to
0N/A enable this module, the default file is distributed at
0N/A <
code>
conf/
magic</
code>. Non-rooted paths are relative to the
0N/A ServerRoot. Virtual hosts will use the same file as the main
0N/A server unless a more specific setting is used, in which case
0N/A the more specific setting overrides the main server's file.</
p>
0N/A<
hr/><
h3 align="center">Apache HTTP Server Version 2.0</
h3><
a href="./"><
img alt="Index" src="/images/index.gif"/></
a><
a href="../"><
img alt="Home" src="/images/home.gif"/></
a></
blockquote></
body></
html>