1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308
|
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="fr" xml:lang="fr"><head><!--
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
This file is generated from xml source: DO NOT EDIT
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-->
<title>mod_mime_magic - Serveur Apache HTTP Version 2.4</title>
<link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
<link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
<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" />
<script src="../style/scripts/prettify.min.js" type="text/javascript">
</script>
<link href="../images/favicon.ico" rel="shortcut icon" /></head>
<body>
<div id="page-header">
<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">Glossaire</a> | <a href="../sitemap.html">Plan du site</a></p>
<p class="apache">Serveur Apache HTTP Version 2.4</p>
<img alt="" src="../images/feather.gif" /></div>
<div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div>
<div id="path">
<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">Serveur HTTP</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.4</a> > <a href="./">Modules</a></div>
<div id="page-content">
<div id="preamble"><h1>Module Apache mod_mime_magic</h1>
<div class="toplang">
<p><span>Langues Disponibles: </span><a href="../en/mod/mod_mime_magic.html" hreflang="en" rel="alternate" title="English"> en </a> |
<a href="../fr/mod/mod_mime_magic.html" title="Franais"> fr </a></p>
</div>
<table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Dtermine le type MIME d'un fichier partir de quelques
octets de son contenu</td></tr>
<tr><th><a href="module-dict.html#Status">Statut:</a></th><td>Extension</td></tr>
<tr><th><a href="module-dict.html#ModuleIdentifier">IdentificateurdeModule:</a></th><td>mime_magic_module</td></tr>
<tr><th><a href="module-dict.html#SourceFile">FichierSource:</a></th><td>mod_mime_magic.c</td></tr></table>
<h3>Sommaire</h3>
<p>Ce module permet de dterminer le <a class="glossarylink" href="../glossary.html#mime-type" title="voir glossaire">type
MIME</a> des fichiers de la mme manire que la commande Unix
<code>file(1)</code>, savoir en se basant sur les premiers octets
du fichier. Il est conu comme une "seconde ligne de dfense" pour
les cas o <code class="module"><a href="../mod/mod_mime.html">mod_mime</a></code> ne parvient pas dterminer le
type du fichier.</p>
<p>Ce module est driv d'une version libre de la commande Unix
<code>file(1)</code> qui utilise des "nombres magiques" et autres
marques distinctives issus du contenu du fichier pour essayer de
dterminer le type de contenu. Ce module n'est activ que si le
fichier magique est spcifi par la directive <code class="directive"><a href="#mimemagicfile">MimeMagicFile</a></code>.</p>
</div>
<div id="quickview"><h3 class="directives">Directives</h3>
<ul id="toc">
<li><img alt="" src="../images/down.gif" /> <a href="#mimemagicfile">MimeMagicFile</a></li>
</ul>
<h3>Sujets</h3>
<ul id="topics">
<li><img alt="" src="../images/down.gif" /> <a href="#format">Format du fichier magique</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#performance">Problmes lis aux performances</a></li>
<li><img alt="" src="../images/down.gif" /> <a href="#notes">Notes</a></li>
</ul><ul class="seealso"><li><a href="#comments_section">Commentaires</a></li></ul></div>
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<h2><a name="format" id="format">Format du fichier magique</a></h2>
<p>Le fichier contient du texte ASCII sur 4 5 colonnes. Les lignes
vides sont autorises mais ignores. Toute ligne commenant par un
dise (<code>#</code>) est un commentaire. Les autres lignes sont
interprtes en colonnes comme suit :</p>
<table class="bordered"><tr class="header"><th>Colonne</th><th>Description</th></tr>
<tr><td>1</td>
<td>numro de l'octet partir duquel la vrification dbute<br />
"<code>></code>" indique une dpendance par rapport la
dernire ligne non-"<code>></code>"</td></tr>
<tr class="odd"><td>2</td>
<td><p>type de donne rechercher</p>
<table class="bordered">
<tr><td><code>byte</code></td>
<td>caractre unique</td></tr>
<tr><td><code>short</code></td>
<td>entier sur 16 bits selon l'ordre de la machine</td></tr>
<tr><td><code>long</code></td>
<td>entier sur 32 bits selon l'ordre de la machine</td></tr>
<tr><td><code>string</code></td>
<td>chane de taille choisie</td></tr>
<tr><td><code>date</code></td>
<td>date au format entier long (secondes depuis le temps Unix epoch/1970)</td></tr>
<tr><td><code>beshort</code></td>
<td>entier 16 bits big-endian</td></tr>
<tr><td><code>belong</code></td>
<td>entier 32 bits big-endian</td></tr>
<tr><td><code>bedate</code></td>
<td>date au format entier 32 bits big-endian</td></tr>
<tr><td><code>leshort</code></td>
<td>entier 16 bits little-endian</td></tr>
<tr><td><code>lelong</code></td>
<td>entier 32 bits little-endian</td></tr>
<tr><td><code>ledate</code></td>
<td>date au format entier 32 bits little-endian</td></tr>
</table></td></tr>
<tr><td>3</td>
<td>contenu des donnes rechercher</td></tr>
<tr class="odd"><td>4</td>
<td>type MIME si correspondance</td></tr>
<tr><td>5</td>
<td>codage MIME si correspondance (optionnel)</td></tr>
</table>
<p>Par exemple, les lignes du fichier magique suivantes
permettraient de reconnatre certains formats audio :</p>
<div class="example"><pre># Sun/NeXT audio data
0 string .snd
>12 belong 1 audio/basic
>12 belong 2 audio/basic
>12 belong 3 audio/basic
>12 belong 4 audio/basic
>12 belong 5 audio/basic
>12 belong 6 audio/basic
>12 belong 7 audio/basic
>12 belong 23 audio/x-adpcm</pre></div>
<p>Et celles-ci permettraient de reconnatre la diffrence entre les
fichiers <code>*.doc</code> qui contiennent des documents Microsoft
Word et les documents FrameMaker (ce sont des formats de fichiers
incompatibles qui possdent le mme suffixe).</p>
<div class="example"><pre># Frame
0 string \<MakerFile application/x-frame
0 string \<MIFFile application/x-frame
0 string \<MakerDictionary application/x-frame
0 string \<MakerScreenFon application/x-frame
0 string \<MML application/x-frame
0 string \<Book application/x-frame
0 string \<Maker application/x-frame
# MS-Word
0 string \376\067\0\043 application/msword
0 string \320\317\021\340\241\261 application/msword
0 string \333\245-\0\0\0 application/msword</pre></div>
<p>Un champ optionnel codage MIME peut tre ajout dans la cinquime
colonne. Par exemple, cette ligne permet de reconnatre les fichiers
compresss par gzip et dfinissent le type de codage.</p>
<div class="example"><pre># gzip (GNU zip, ne pas confondre avec
# l'archiveur zip [Info-ZIP/PKWARE])
0 string \037\213 application/octet-stream x-gzip</pre></div>
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<h2><a name="performance" id="performance">Problmes lis aux performances</a></h2>
<p>Ce module n'est pas fait pour tous les systmes. Si votre systme
parvient peine supporter sa charge, ou si vous testez les
performances d'un serveur web, il est dconseill d'utiliser ce
module car son fonctionnement a un prix en matire de ressources
consommes.</p>
<p>Des efforts ont cependant t fournis pour amliorer les
performances du code original de la commande <code>file(1)</code> en
l'adaptant pour fonctionner sur un serveur web forte charge. Il a
t conu pour un serveur sur lequel des milliers d'utilisateurs
publient leurs propres documents, ce qui est probablement trs
courant sur un intranet. Il s'avre souvent bnfique qu'un serveur
puisse prendre des dcisions plus pertinentes propos du contenu
d'un fichier que celles se basant sur le nom du fichier seul, ne
serait-ce que pour diminuer le nombre d'appels du type "pourquoi ma
page ne s'affiche-t-elle pas ?" survenant lorsque les utilisateurs
nomment leurs fichiers incorrectement. Vous devez dterminer si la
charge supplmentaire convient votre environnement.</p>
</div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="section">
<h2><a name="notes" id="notes">Notes</a></h2>
<p>Les notes suivantes s'appliquent au module
<code class="module"><a href="../mod/mod_mime_magic.html">mod_mime_magic</a></code> et sont incluses ici pour
conformit avec les restrictions de copyright des contributeurs
qui requirent de les accepter.</p>
<p>Note de traduction : ces informations de type lgal ne sont pas traductibles</p>
<div class="note">
<p>mod_mime_magic: MIME type lookup via file magic numbers<br />
Copyright (c) 1996-1997 Cisco Systems, Inc.</p>
<p>This software was submitted by Cisco Systems to the Apache Group
in July 1997. Future revisions and derivatives of this source code
must acknowledge Cisco Systems as the original contributor of this
module. All other licensing and usage conditions are those of the
Apache Group.</p>
<p>Some of this code is derived from the free version of the file
command originally posted to comp.sources.unix. Copyright info for
that program is included below as required.</p>
</div>
<div class="note">
<p> - Copyright (c) Ian F. Darwin, 1987. Written by Ian F. Darwin.</p>
<p>This software is not subject to any license of the American
Telephone and Telegraph Company or of the Regents of the University
of California.</p>
<p>Permission is granted to anyone to use this software for any
purpose on any computer system, and to alter it and redistribute it
freely, subject to the following restrictions:</p>
<ol>
<li>The author is not responsible for the consequences of use of
this software, no matter how awful, even if they arise from flaws
in it.</li>
<li>The origin of this software must not be misrepresented, either
by explicit claim or by omission. Since few users ever read
sources, credits must appear in the documentation.</li>
<li>Altered versions must be plainly marked as such, and must not
be misrepresented as being the original software. Since few users
ever read sources, credits must appear in the documentation.</li>
<li>This notice may not be removed or altered.</li>
</ol>
</div>
<div class="note">
<p>For compliance with Mr Darwin's terms: this has been very
significantly modified from the free "file" command.</p>
<ul>
<li>all-in-one file for compilation convenience when moving from
one version of Apache to the next.</li>
<li>Memory allocation is done through the Apache API's pool
structure.</li>
<li>All functions have had necessary Apache API request or server
structures passed to them where necessary to call other Apache API
routines. (<em>i.e.</em>, usually for logging, files, or memory
allocation in itself or a called function.)</li>
<li>struct magic has been converted from an array to a single-ended
linked list because it only grows one record at a time, it's only
accessed sequentially, and the Apache API has no equivalent of
<code>realloc()</code>.</li>
<li>Functions have been changed to get their parameters from the
server configuration instead of globals. (It should be reentrant
now but has not been tested in a threaded environment.)</li>
<li>Places where it used to print results to stdout now saves them
in a list where they're used to set the MIME type in the Apache
request record.</li>
<li>Command-line flags have been removed since they will never be
used here.</li>
</ul>
</div>
</div>
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="directive-section"><h2><a name="MimeMagicFile" id="MimeMagicFile">MimeMagicFile</a> <a name="mimemagicfile" id="mimemagicfile">Directive</a></h2>
<table class="directive">
<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Active la dtermination du type MIME en se basant sur le
contenu du fichier et en utilisant le fichier magique
spcifi</td></tr>
<tr><th><a href="directive-dict.html#Syntax">Syntaxe:</a></th><td><code>MimeMagicFile <var>chemin-fichier</var></code></td></tr>
<tr><th><a href="directive-dict.html#Context">Contexte:</a></th><td>configuration du serveur, serveur virtuel</td></tr>
<tr><th><a href="directive-dict.html#Status">Statut:</a></th><td>Extension</td></tr>
<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_mime_magic</td></tr>
</table>
<p>La directive <code class="directive">MimeMagicFile</code> permet
d'activer ce module, le fichier par dfaut fourni tant
<code>conf/magic</code>. Les chemins sans slash '/' de dbut sont
relatifs au rpertoire dfini par la directive <code class="directive"><a href="../mod/core.html#serverroot">ServerRoot</a></code>. Les serveurs virtuels
utilisent le mme fichier que le serveur principal sauf si un
fichier spcifique a t dfini pour ce serveur virtuel, auquel cas
c'est ce dernier fichier qui sera utilis.</p>
<div class="example"><h3>Exemple</h3><pre class="prettyprint lang-config">MimeMagicFile conf/magic</pre>
</div>
</div>
</div>
<div class="bottomlang">
<p><span>Langues Disponibles: </span><a href="../en/mod/mod_mime_magic.html" hreflang="en" rel="alternate" title="English"> en </a> |
<a href="../fr/mod/mod_mime_magic.html" title="Franais"> fr </a></p>
</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">Commentaires</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&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>
<script type="text/javascript"><!--//--><![CDATA[//><!--
var comments_shortname = 'httpd';
var comments_identifier = 'http://httpd.apache.org/docs/2.4/mod/mod_mime_magic.html';
(function(w, d) {
if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
d.write('<div id="comments_thread"><\/div>');
var s = d.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
(d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
}
else {
d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
}
})(window, document);
//--><!]]></script></div><div id="footer">
<p class="apache">Copyright 2014 The Apache Software Foundation.<br />Autoris sous <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
<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">Glossaire</a> | <a href="../sitemap.html">Plan du site</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
if (typeof(prettyPrint) !== 'undefined') {
prettyPrint();
}
//--><!]]></script>
</body></html>
|