1 <?xml version="1.0" encoding="UTF-8" ?>
2 <!DOCTYPE manualpage SYSTEM "./style/manualpage.dtd">
3 <?xml-stylesheet type="text/xsl" href="./style/manual.en.xsl"?>
4 <!-- $LastChangedRevision$ -->
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
14 http://www.apache.org/licenses/LICENSE-2.0
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.
23 <manualpage metafile="handler.xml.meta">
25 <title>Apache's Handler Use</title>
28 <p>This document describes the use of Apache's Handlers.</p>
31 <section id="definition">
32 <title>What is a Handler</title>
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>
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>
53 <p>A "handler" is an internal Apache representation of the
54 action to be performed when a file is called. Generally, files
55 have implicit handlers, based on the file type. Normally, all
56 files are simply served by the server, but certain file types
57 are "handled" separately.</p>
59 <p>Handlers may also be configured explicitly,
60 based on either filename extensions or on location,
61 without relation to file type. This is
62 advantageous both because it is a more elegant solution, and
63 because it also allows for both a type <strong>and</strong> a
64 handler to be associated with a file. (See also <a
65 href="mod/mod_mime.html#multipleext">Files with Multiple
68 <p>Handlers can either be built into the server or included in
69 a module, or they can be added with the <directive
70 module="mod_actions">Action</directive> directive. The
71 built-in handlers in the standard distribution are as
75 <li><strong>default-handler</strong>: Send the file using the
76 <code>default_handler()</code>, which is the handler used by
77 default to handle static content. (core)</li>
79 <li><strong>send-as-is</strong>: Send file with HTTP headers
80 as is. (<module>mod_asis</module>)</li>
82 <li><strong>cgi-script</strong>: Treat the file as a CGI
83 script. (<module>mod_cgi</module>)</li>
85 <li><strong>imap-file</strong>: Parse as an imagemap rule
86 file. (<module>mod_imagemap</module>)</li>
88 <li><strong>server-info</strong>: Get the server's
89 configuration information. (<module>mod_info</module>)</li>
91 <li><strong>server-status</strong>: Get the server's status
92 report. (<module>mod_status</module>)</li>
94 <li><strong>type-map</strong>: Parse as a type map file for
95 content negotiation. (<module>mod_negotiation</module>)</li>
98 <section id="examples">
99 <title>Examples</title>
101 <section id="example1">
102 <title>Modifying static content using a CGI script</title>
104 <p>The following directives will cause requests for files with
105 the <code>html</code> extension to trigger the launch of the
106 <code>footer.pl</code> CGI script.</p>
109 Action add-footer /cgi-bin/footer.pl<br/>
110 AddHandler add-footer .html
113 <p>Then the CGI script is responsible for sending the
114 originally requested document (pointed to by the
115 <code>PATH_TRANSLATED</code> environment variable) and making
116 whatever modifications or additions are desired.</p>
119 <section id="example2">
120 <title>Files with HTTP headers</title>
122 <p>The following directives will enable the
123 <code>send-as-is</code> handler, which is used for files which
124 contain their own HTTP headers. All files in the
125 <code>/web/htdocs/asis/</code> directory will be processed by
126 the <code>send-as-is</code> handler, regardless of their
127 filename extensions.</p>
130 <Directory /web/htdocs/asis><br/>
131 SetHandler send-as-is<br/>
137 <section id="programmer">
138 <title>Programmer's Note</title>
140 <p>In order to implement the handler features, an addition has
141 been made to the <a href="developer/API.html">Apache API</a> that
142 you may wish to make use of. Specifically, a new record has
143 been added to the <code>request_rec</code> structure:</p>
149 <p>If you wish to have your module engage a handler, you need
150 only to set <code>r->handler</code> to the name of the
151 handler at any time prior to the <code>invoke_handler</code>
152 stage of the request. Handlers are implemented as they were
153 before, albeit using the handler name instead of a content
154 type. While it is not necessary, the naming convention for
155 handlers is to use a dash-separated word, with no slashes, so
156 as to not invade the media type name-space.</p>