handler.html.en revision 1e86aafffa12e58c7cfe4244690eff3b82bd02c4
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes BGCOLOR="#FFFFFF"
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes TEXT="#000000"
0662ed52e814f8f08ef0e09956413a792584eddffuankg LINK="#0000FF"
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes VLINK="#000080"
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes ALINK="#FF0000"
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes<!--#include virtual="header.html" -->
70953fb44a7140fe206c3a5f011e24209c8c5c6abnicholes<li><a href="#definition">What is a Handler</a></li>
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes<H2><a name="definition">What is a Handler</a></H2>
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes<A HREF="mod/mod_negotiation.html">mod_negotiation</A><br>
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes<a href="mod/mod_actions.html#action">Action</a><br>
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes<A HREF="mod/mod_mime.html#addhandler">AddHandler</A><br>
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes<a href="mod/mod_mime.html#removehandler">RemoveHandler</a><br>
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes<A HREF="mod/mod_mime.html#sethandler">SetHandler</A><br>
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes<P>A "handler" is an internal Apache representation of the action to be
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesperformed when a file is called. Generally, files have implicit
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholeshandlers, based on the file type. Normally, all files are simply
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesserved by the server, but certain file types are "handled"
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesseparately.</P>
ac7985784d08a3655291f24f711812b4d8b1cbcffuankg<P>Apache 1.1 adds the ability to use handlers explicitly. Based on
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholeseither filename extensions or on location, handlers can be specified
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholeswithout relation to file type. This is advantageous both because it is
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesa more elegant solution, and because it also allows for both a type
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes<STRONG>and</STRONG> a handler to be associated with a file. (See also
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes<A HREF="mod/mod_mime.html#multipleext">Files with Multiple
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes<P>Handlers can either be built into the server or included in a module,
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesor they can be added with the <A
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesHREF="mod/mod_actions.html#action">Action</A> directive. The built-in
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholeshandlers in the standard distribution are as follows:</P>
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes Send the file using the <CODE>default_handler()</CODE>, which is the
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes handler used by default to handle static content.
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes Send file with HTTP headers as is.
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes Treat the file as a CGI script.
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes Parse as an imagemap rule file.
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes Get the server's configuration information.
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes Parse for server-side includes.
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes Get the server's status report.
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes Parse as a type map file for content negotiation.
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes (<A HREF="mod/mod_negotiation.html">mod_negotiation</A>)
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes<h3>Modifying static content using a CGI script</h3>
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes<p>The following directives will cause requests for files with the
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes<code>html</code> extension to trigger the launch of the
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes AddHandler add-footer .html
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes<p>Then the CGI script is responsible for sending the originally
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesrequested document (pointed to by the <code>PATH_TRANSLATED</code>
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesenvironment variable) and making whatever modifications or additions
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesare desired.</p>
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes<p>The following directives will enable the <code>send-as-is</code>
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholeshandler, which is used for files which contain their own HTTP headers.
0662ed52e814f8f08ef0e09956413a792584eddffuankgAll files in the <code>/web/htdocs/asis/</code> directory will be
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesprocessed by the <code>send-as-is</code> handler, regardless of their
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesfilename extensions.</p>
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes SetHandler send-as-is
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes </Directory>
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes<H2><a name="programmer">Programmer's Note</a></H2>
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes<P>In order to implement the handler features, an addition has been
0662ed52e814f8f08ef0e09956413a792584eddffuankgmade to the <A HREF="misc/API.html">Apache API</A> that you may wish to
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesmake use of. Specifically, a new record has been added to the
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes char *handler
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes<P>If you wish to have your module engage a handler, you need only to
ac7985784d08a3655291f24f711812b4d8b1cbcffuankgset <CODE>r->handler</CODE> to the name of the handler at any time
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesprior to the <CODE>invoke_handler</CODE> stage of the
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesrequest. Handlers are implemented as they were before, albeit using
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesthe handler name instead of a content type. While it is not
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesnecessary, the naming convention for handlers is to use a
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholesdash-separated word, with no slashes, so as to not invade the media
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholestype name-space.</P>
3c937b528ca923d5b51e63def9f888af4a77bb40bnicholes<!--#include virtual="footer.html" -->