github.com/krum110487/go-htaccess@v0.0.0-20240316004156-60641c8e7598/tests/data/apache_2_2_34/manual/mod/mod_mime_magic.html.en (about)

     1  <?xml version="1.0" encoding="ISO-8859-1"?>
     2  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
     3  <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
     4  <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type" />
     5  <!--
     6          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
     7                This file is generated from xml source: DO NOT EDIT
     8          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
     9        -->
    10  <title>mod_mime_magic - Apache HTTP Server Version 2.2</title>
    11  <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
    12  <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
    13  <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" />
    14  <script src="../style/scripts/prettify.min.js" type="text/javascript">
    15  </script>
    16  
    17  <link href="../images/favicon.ico" rel="shortcut icon" /><link href="http://httpd.apache.org/docs/current/mod/mod_mime_magic.html" rel="canonical" /></head>
    18  <body>
    19  <div id="page-header">
    20  <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
    21  <p class="apache">Apache HTTP Server Version 2.2</p>
    22  <img alt="" src="../images/feather.gif" /></div>
    23  <div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="../images/left.gif" /></a></div>
    24  <div id="path">
    25  <a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="../">Version 2.2</a> &gt; <a href="./">Modules</a></div>
    26  <div id="page-content">
    27  <div class="retired"><h4>Please note</h4>
    28              <p> This document refers to a legacy release (<strong>2.2</strong>) of Apache httpd. The active release (<strong>2.4</strong>) is documented <a href="http://httpd.apache.org/docs/current">here</a>. If you have not already upgraded, please follow <a href="http://httpd.apache.org/docs/current/upgrading.html">this link</a> for more information.</p>
    29          <p>You may follow <a href="http://httpd.apache.org/docs/current/mod/mod_mime_magic.html">this link</a> to go to the current version of this document.</p></div><div id="preamble"><h1>Apache Module mod_mime_magic</h1>
    30  <div class="toplang">
    31  <p><span>Available Languages: </span><a href="../en/mod/mod_mime_magic.html" title="English">&nbsp;en&nbsp;</a></p>
    32  </div>
    33  <table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Determines the MIME type of a file
    34      by looking at a few bytes of its contents</td></tr>
    35  <tr><th><a href="module-dict.html#Status">Status:</a></th><td>Extension</td></tr>
    36  <tr><th><a href="module-dict.html#ModuleIdentifier">Module Identifier:</a></th><td>mime_magic_module</td></tr>
    37  <tr><th><a href="module-dict.html#SourceFile">Source File:</a></th><td>mod_mime_magic.c</td></tr></table>
    38  <h3>Summary</h3>
    39  
    40      <p>This module determines the <a class="glossarylink" href="../glossary.html#mime-type" title="see glossary">MIME
    41      type</a> of files in the same way the Unix
    42      <code>file(1)</code> command works: it looks at the first few
    43      bytes of the file. It is intended as a "second line of defense"
    44      for cases that <code class="module"><a href="../mod/mod_mime.html">mod_mime</a></code> can't resolve.</p>
    45  
    46      <p>This module is derived from a free version of the
    47      <code>file(1)</code> command for Unix, which uses "magic
    48      numbers" and other hints from a file's contents to figure out
    49      what the contents are. This module is active only if the magic
    50      file is specified by the <code class="directive"><a href="#mimemagicfile">MimeMagicFile</a></code> directive.</p>
    51  </div>
    52  <div id="quickview"><h3>Topics</h3>
    53  <ul id="topics">
    54  <li><img alt="" src="../images/down.gif" /> <a href="#format">Format of the Magic File</a></li>
    55  <li><img alt="" src="../images/down.gif" /> <a href="#performance">Performance Issues</a></li>
    56  <li><img alt="" src="../images/down.gif" /> <a href="#notes">Notes</a></li>
    57  </ul><h3 class="directives">Directives</h3>
    58  <ul id="toc">
    59  <li><img alt="" src="../images/down.gif" /> <a href="#mimemagicfile">MimeMagicFile</a></li>
    60  </ul>
    61  <ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
    62  <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
    63  <div class="section">
    64  <h2><a name="format" id="format">Format of the Magic File</a></h2>
    65  
    66      <p>The contents of the file are plain ASCII text in 4-5
    67      columns. Blank lines are allowed but ignored. Commented lines
    68      use a hash mark (<code>#</code>). The remaining lines are parsed for
    69      the following columns:</p>
    70  
    71      <table class="bordered"><tr class="header"><th>Column</th><th>Description</th></tr>
    72  <tr><td>1</td>
    73          <td>byte number to begin checking from<br />
    74           "<code>&gt;</code>" indicates a dependency upon the previous
    75           non-"<code>&gt;</code>" line</td></tr>
    76  <tr class="odd"><td>2</td>
    77          <td><p>type of data to match</p>
    78          <table class="bordered">
    79          
    80          <tr><td><code>byte</code></td>
    81              <td>single character</td></tr>
    82          <tr><td><code>short</code></td>
    83              <td>machine-order 16-bit integer</td></tr>
    84          <tr><td><code>long</code></td>
    85              <td>machine-order 32-bit integer</td></tr>
    86          <tr><td><code>string</code></td>
    87              <td>arbitrary-length string</td></tr>
    88          <tr><td><code>date</code></td>
    89              <td>long integer date (seconds since Unix epoch/1970)</td></tr>
    90          <tr><td><code>beshort</code></td>
    91              <td>big-endian 16-bit integer</td></tr>
    92          <tr><td><code>belong</code></td>
    93              <td>big-endian 32-bit integer</td></tr>
    94          <tr><td><code>bedate</code></td>
    95              <td>big-endian 32-bit integer date</td></tr>
    96          <tr><td><code>leshort</code></td>
    97              <td>little-endian 16-bit integer</td></tr>
    98          <tr><td><code>lelong</code></td>
    99              <td>little-endian 32-bit integer</td></tr>
   100          <tr><td><code>ledate</code></td>
   101              <td>little-endian 32-bit integer date</td></tr>
   102          </table></td></tr>
   103  <tr><td>3</td>
   104          <td>contents of data to match</td></tr>
   105  <tr class="odd"><td>4</td>
   106          <td>MIME type if matched</td></tr>
   107  <tr><td>5</td>
   108          <td>MIME encoding if matched (optional)</td></tr>
   109  </table>
   110  
   111      <p>For example, the following magic file lines would recognize
   112      some audio formats:</p>
   113  
   114      <div class="example"><pre># Sun/NeXT audio data
   115  0      string      .snd
   116  &gt;12    belong      1       audio/basic
   117  &gt;12    belong      2       audio/basic
   118  &gt;12    belong      3       audio/basic
   119  &gt;12    belong      4       audio/basic
   120  &gt;12    belong      5       audio/basic
   121  &gt;12    belong      6       audio/basic
   122  &gt;12    belong      7       audio/basic
   123  &gt;12    belong     23       audio/x-adpcm</pre></div>
   124  
   125      <p>Or these would recognize the difference between <code>*.doc</code>
   126      files containing Microsoft Word or FrameMaker documents. (These are
   127      incompatible file formats which use the same file suffix.)</p>
   128  
   129      <div class="example"><pre># Frame
   130  0  string  \&lt;MakerFile        application/x-frame
   131  0  string  \&lt;MIFFile          application/x-frame
   132  0  string  \&lt;MakerDictionary  application/x-frame
   133  0  string  \&lt;MakerScreenFon   application/x-frame
   134  0  string  \&lt;MML              application/x-frame
   135  0  string  \&lt;Book             application/x-frame
   136  0  string  \&lt;Maker            application/x-frame
   137  
   138  # MS-Word
   139  0  string  \376\067\0\043            application/msword
   140  0  string  \320\317\021\340\241\261  application/msword
   141  0  string  \333\245-\0\0\0           application/msword</pre></div>
   142  
   143      <p>An optional MIME encoding can be included as a fifth column.
   144      For example, this can recognize gzipped files and set the
   145      encoding for them.</p>
   146  
   147      <div class="example"><pre># gzip (GNU zip, not to be confused with
   148  #       [Info-ZIP/PKWARE] zip archiver)
   149  
   150  0  string  \037\213  application/octet-stream  x-gzip</pre></div>
   151  </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
   152  <div class="section">
   153  <h2><a name="performance" id="performance">Performance Issues</a></h2>
   154      <p>This module is not for every system. If your system is barely
   155      keeping up with its load or if you're performing a web server
   156      benchmark, you may not want to enable this because the
   157      processing is not free.</p>
   158  
   159      <p>However, an effort was made to improve the performance of
   160      the original <code>file(1)</code> code to make it fit in a busy web
   161      server. It was designed for a server where there are thousands of users
   162      who publish their own documents. This is probably very common
   163      on intranets. Many times, it's helpful if the server can make
   164      more intelligent decisions about a file's contents than the
   165      file name allows ...even if just to reduce the "why doesn't my
   166      page work" calls when users improperly name their own files.
   167      You have to decide if the extra work suits your
   168      environment.</p>
   169  </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
   170  <div class="section">
   171  <h2><a name="notes" id="notes">Notes</a></h2>
   172      <p>The following notes apply to the <code class="module"><a href="../mod/mod_mime_magic.html">mod_mime_magic</a></code>
   173      module and are included here for compliance with contributors'
   174      copyright restrictions that require their acknowledgment.</p>
   175  
   176      <div class="note">
   177        <p>mod_mime_magic: MIME type lookup via file magic numbers<br />
   178        Copyright (c) 1996-1997 Cisco Systems, Inc.</p>
   179  
   180        <p>This software was submitted by Cisco Systems to the Apache Group
   181        in July 1997. Future revisions and derivatives of this source code
   182        must acknowledge Cisco Systems as the original contributor of this
   183        module. All other licensing and usage conditions are those of the
   184        Apache Group.</p>
   185  
   186        <p>Some of this code is derived from the free version of the file
   187        command originally posted to comp.sources.unix. Copyright info for
   188        that program is included below as required.</p>
   189      </div>
   190  
   191      <div class="note">
   192        <p> - Copyright (c) Ian F. Darwin, 1987. Written by Ian F. Darwin.</p>
   193  
   194        <p>This software is not subject to any license of the American
   195        Telephone and Telegraph Company or of the Regents of the University
   196        of California.</p>
   197  
   198        <p>Permission is granted to anyone to use this software for any
   199        purpose on any computer system, and to alter it and redistribute it
   200        freely, subject to the following restrictions:</p>
   201  
   202        <ol>
   203          <li>The author is not responsible for the consequences of use of
   204          this software, no matter how awful, even if they arise from flaws
   205          in it.</li>
   206  
   207          <li>The origin of this software must not be misrepresented, either
   208          by explicit claim or by omission. Since few users ever read
   209          sources, credits must appear in the documentation.</li>
   210  
   211          <li>Altered versions must be plainly marked as such, and must not
   212          be misrepresented as being the original software. Since few users
   213          ever read sources, credits must appear in the documentation.</li>
   214  
   215          <li>This notice may not be removed or altered.</li>
   216        </ol>
   217      </div>
   218  
   219      <div class="note">
   220        <p>For compliance with Mr Darwin's terms: this has been very
   221        significantly modified from the free "file" command.</p>
   222  
   223        <ul>
   224          <li>all-in-one file for compilation convenience when moving from
   225          one version of Apache to the next.</li>
   226  
   227          <li>Memory allocation is done through the Apache API's pool
   228          structure.</li>
   229  
   230          <li>All functions have had necessary Apache API request or server
   231          structures passed to them where necessary to call other Apache API
   232          routines. (<em>i.e.</em>, usually for logging, files, or memory
   233          allocation in itself or a called function.)</li>
   234  
   235          <li>struct magic has been converted from an array to a single-ended
   236          linked list because it only grows one record at a time, it's only
   237          accessed sequentially, and the Apache API has no equivalent of
   238          <code>realloc()</code>.</li>
   239  
   240          <li>Functions have been changed to get their parameters from the
   241          server configuration instead of globals.  (It should be reentrant
   242          now but has not been tested in a threaded environment.)</li>
   243  
   244          <li>Places where it used to print results to stdout now saves them
   245          in a list where they're used to set the MIME type in the Apache
   246          request record.</li>
   247  
   248          <li>Command-line flags have been removed since they will never be
   249          used here.</li>
   250        </ul>
   251      </div>
   252  </div>
   253  <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
   254  <div class="directive-section"><h2><a name="MimeMagicFile" id="MimeMagicFile">MimeMagicFile</a> <a name="mimemagicfile" id="mimemagicfile">Directive</a></h2>
   255  <table class="directive">
   256  <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Enable MIME-type determination based on file contents
   257  using the specified magic file</td></tr>
   258  <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>MimeMagicFile <var>file-path</var></code></td></tr>
   259  <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
   260  <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
   261  <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_mime_magic</td></tr>
   262  </table>
   263      <p>The <code class="directive">MimeMagicFile</code> directive can be used to
   264      enable this module, the default file is distributed at
   265      <code>conf/magic</code>. Non-rooted paths are relative to the
   266      <code class="directive"><a href="../mod/core.html#serverroot">ServerRoot</a></code>. Virtual hosts will use
   267      the same file as the main server unless a more specific setting is
   268      used, in which case the more specific setting overrides the main
   269      server's file.</p>
   270  
   271      <div class="example"><h3>Example</h3><p><code>
   272        MimeMagicFile conf/magic
   273      </code></p></div>
   274  
   275  </div>
   276  </div>
   277  <div class="bottomlang">
   278  <p><span>Available Languages: </span><a href="../en/mod/mod_mime_magic.html" title="English">&nbsp;en&nbsp;</a></p>
   279  </div><div class="top"><a href="#page-header"><img src="../images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&amp;A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
   280  <script type="text/javascript"><!--//--><![CDATA[//><!--
   281  var comments_shortname = 'httpd';
   282  var comments_identifier = 'http://httpd.apache.org/docs/2.2/mod/mod_mime_magic.html';
   283  (function(w, d) {
   284      if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
   285          d.write('<div id="comments_thread"><\/div>');
   286          var s = d.createElement('script');
   287          s.type = 'text/javascript';
   288          s.async = true;
   289          s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
   290          (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
   291      }
   292      else { 
   293          d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
   294      }
   295  })(window, document);
   296  //--><!]]></script></div><div id="footer">
   297  <p class="apache">Copyright 2017 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
   298  <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
   299  if (typeof(prettyPrint) !== 'undefined') {
   300      prettyPrint();
   301  }
   302  //--><!]]></script>
   303  </body></html>