]> granicus.if.org Git - apache/blob - docs/manual/handler.xml.ja
Remove useless <br \> in highlight blocks.
[apache] / docs / manual / handler.xml.ja
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <!DOCTYPE manualpage SYSTEM "./style/manualpage.dtd">
3 <?xml-stylesheet type="text/xsl" href="./style/manual.ja.xsl"?>
4 <!-- English Revision: 1334033:1673563 (outdated) -->
5
6 <!--
7  Licensed to the Apache Software Foundation (ASF) under one or more
8  contributor license agreements.  See the NOTICE file distributed with
9  this work for additional information regarding copyright ownership.
10  The ASF licenses this file to You under the Apache License, Version 2.0
11  (the "License"); you may not use this file except in compliance with
12  the License.  You may obtain a copy of the License at
13
14      http://www.apache.org/licenses/LICENSE-2.0
15
16  Unless required by applicable law or agreed to in writing, software
17  distributed under the License is distributed on an "AS IS" BASIS,
18  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  See the License for the specific language governing permissions and
20  limitations under the License.
21 -->
22
23 <manualpage metafile="handler.xml.meta">
24
25   <title>Apache のハンドラの使用</title>
26
27   <summary>
28     <p>Apache のハンドラの使用に関して記述しています。</p>
29   </summary>
30
31   <section id="definition">
32     <title>ハンドラとは</title>
33     <related>
34       <modulelist>
35         <module>mod_actions</module>
36         <module>mod_asis</module>
37         <module>mod_cgi</module>
38         <module>mod_imagemap</module>
39         <module>mod_info</module>
40         <module>mod_mime</module>
41         <module>mod_negotiation</module>
42         <module>mod_status</module>
43      </modulelist>
44       <directivelist>
45         <directive module="mod_actions">Action</directive>
46         <directive module="mod_mime">AddHandler</directive>
47         <directive module="mod_mime">RemoveHandler</directive>
48         <directive module="core">SetHandler</directive>
49       </directivelist>
50     </related>
51
52
53     <p>「ハンドラ」とは、ファイルが呼ばれたときに実行される動作の
54     Apache における内部表現です。
55     通常、ファイルはファイルタイプ<transnote>MIME-type</transnote
56     >に基づいた暗黙のハンドラがあります。
57     普通はすべてのファイルは単にサーバに扱われますが、
58     ファイルタイプの中には別に「ハンドル」<transnote>扱う</transnote>
59     されるものもあります。</p>
60
61     <p>ファイルの拡張子や置いている場所に基づいてファイルタイプと関係なく、
62     ハンドラを明示的に設定することもできます。
63     これはより優雅な解決法という点と、ファイルにタイプ<strong>と</strong
64     >ハンドラの両方を関連付けることができるという点で優れています。
65     (<a href="mod/mod_mime.html#multipleext"
66     >複数の拡張子のあるファイル</a>も参照してください)。</p>
67
68     <p>ハンドラはサーバに組み込んだり、モジュールとして含めたり、
69     <directive module="mod_actions">Action</directive>
70     ディレクティブとして追加したりすることができます。
71     以下は標準配布に組み込まれているハンドラです。
72     </p>
73
74     <ul>
75       <li><strong>default-handler</strong>:<code>default_handelr()</code>
76       を使ってファイルを送ります。
77       静的なコンテンツを扱うときにデフォルトで使用されるハンドラです。
78       (<module>core</module>)</li>
79
80       <li><strong>send-as-is</strong>:
81       HTTP ヘッダのあるファイルをそのまま送ります。
82       (<module>mod_asis</module>)</li>
83
84       <li><strong>cgi-script</strong>: ファイルを CGI
85       スクリプトとして扱います。
86       (<module>mod_cgi</module>)</li>
87
88       <li><strong>imap-file</strong>:
89       イメージマップのルールファイルとして解析します。
90       (<module>mod_imagemap</module>)</li>
91
92       <li><strong>server-info</strong>: サーバの設定情報を取得します。
93       (<module>mod_info</module>)</li>
94
95       <li><strong>server-status</strong>: サーバの状態報告を取得します。
96       (<module>mod_status</module>)</li>
97
98       <li><strong>type-map</strong>:
99       コンテントネゴシエーションのためのタイプマップとして解析します。
100       (<module>mod_negotiation</module>)</li>
101     </ul>
102   </section>
103   <section id="examples">
104     <title>例</title>
105
106     <section id="example1">
107       <title>CGI スクリプトを用いて静的なコンテンツを変更する</title>
108
109       <p>以下のディレクティブによって、拡張子が <code>html</code>
110       であるファイルは <code>footer.pl</code>
111       CGI スクリプトを起動するようになります。</p>
112
113       <highlight language="config">
114 Action add-footer /cgi-bin/footer.pl
115 AddHandler add-footer .html
116       </highlight>
117
118       <p>CGI スクリプトは希望の修正や追加を行なって、元々要求された文書
119       (環境変数 <code>PATH_TRANSLATED</code>
120       で指されています) を送る責任があります。
121       </p>
122
123     </section>
124     <section id="example2">
125       <title>HTTP ヘッダのあるファイル</title>
126
127       <p>以下のディレクティブは <code>send-as-is</code>
128       ハンドラを使用するように指示します。このハンドラは自分自身の HTTP
129       ヘッダを持っているファイルに使用されます。ここでは、拡張子に関わらず、
130       <code>/web/htdocs/asis</code> ディレクトリにある全てのファイルは
131       <code>send-as-is</code> ハンドラによって扱われます。</p>
132
133       <highlight language="config">
134 &lt;Directory /web/htdocs/asis&gt;
135     SetHandler send-as-is
136 &lt;/Directory&gt;
137       </highlight>
138
139     </section>
140   </section>
141   <section id="programmer">
142     <title>プログラマ向けのメモ</title>
143
144     <p>ハンドラの機能を実装するために、利用すると便利かもしれないものが
145     <a href="developer/API.html">Apache API</a>
146     に追加されました。詳しく言うと、<code>request_rec</code>
147     構造体に新しいレコードが追加されたということです。</p>
148
149     <highlight language="c">
150       char *handler
151     </highlight>
152
153     <p>もしモジュールがハンドラに関わりたい場合、
154     やらなければならないことは、リクエストが <code>invoke_handler</code>
155     ステージに達する以前に <code>r-&gt;handler</code>
156     を設定することだけです。ハンドラはコンテントタイプの代わりに
157     ハンドラ名を使うようになっていること以外は、以前と同じように実装されています。
158     必ず要求されているわけではありませんが、メディアタイプ
159     の名前空間を侵さないように、ハンドラの名前にはスラッシュを含まない、
160     ダッシュ<transnote>"-"</transnote>で分離された名前を付ける習慣になっています。</p>
161   </section>
162 </manualpage>