handler.html revision 1e86aafffa12e58c7cfe4244690eff3b82bd02c4
f072359f493a5209335799da85ac16d6a273303bgryzor<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
f072359f493a5209335799da85ac16d6a273303bgryzor<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
f072359f493a5209335799da85ac16d6a273303bgryzor BGCOLOR="#FFFFFF"
f072359f493a5209335799da85ac16d6a273303bgryzor TEXT="#000000"
f072359f493a5209335799da85ac16d6a273303bgryzor LINK="#0000FF"
f072359f493a5209335799da85ac16d6a273303bgryzor VLINK="#000080"
f072359f493a5209335799da85ac16d6a273303bgryzor ALINK="#FF0000"
f072359f493a5209335799da85ac16d6a273303bgryzor<!--#include virtual="header.html" -->
f072359f493a5209335799da85ac16d6a273303bgryzor<A HREF="mod/mod_negotiation.html">mod_negotiation</A><br>
f072359f493a5209335799da85ac16d6a273303bgryzor<A HREF="mod/mod_mime.html#addhandler">AddHandler</A><br>
f072359f493a5209335799da85ac16d6a273303bgryzor<a href="mod/mod_mime.html#removehandler">RemoveHandler</a><br>
f072359f493a5209335799da85ac16d6a273303bgryzor<A HREF="mod/mod_mime.html#sethandler">SetHandler</A><br>
f072359f493a5209335799da85ac16d6a273303bgryzor<P>A "handler" is an internal Apache representation of the action to be
f072359f493a5209335799da85ac16d6a273303bgryzorperformed when a file is called. Generally, files have implicit
f072359f493a5209335799da85ac16d6a273303bgryzorhandlers, based on the file type. Normally, all files are simply
f072359f493a5209335799da85ac16d6a273303bgryzorserved by the server, but certain file types are "handled"
f072359f493a5209335799da85ac16d6a273303bgryzorseparately.</P>
f072359f493a5209335799da85ac16d6a273303bgryzor<P>Apache 1.1 adds the ability to use handlers explicitly. Based on
f072359f493a5209335799da85ac16d6a273303bgryzoreither filename extensions or on location, handlers can be specified
f072359f493a5209335799da85ac16d6a273303bgryzorwithout relation to file type. This is advantageous both because it is
f072359f493a5209335799da85ac16d6a273303bgryzora more elegant solution, and because it also allows for both a type
f072359f493a5209335799da85ac16d6a273303bgryzor<STRONG>and</STRONG> a handler to be associated with a file. (See also
f072359f493a5209335799da85ac16d6a273303bgryzor<A HREF="mod/mod_mime.html#multipleext">Files with Multiple
f072359f493a5209335799da85ac16d6a273303bgryzor<P>Handlers can either be built into the server or included in a module,
f072359f493a5209335799da85ac16d6a273303bgryzoror they can be added with the <A
f072359f493a5209335799da85ac16d6a273303bgryzorHREF="mod/mod_actions.html#action">Action</A> directive. The built-in
f072359f493a5209335799da85ac16d6a273303bgryzorhandlers in the standard distribution are as follows:</P>
f072359f493a5209335799da85ac16d6a273303bgryzor Send the file using the <CODE>default_handler()</CODE>, which is the
f072359f493a5209335799da85ac16d6a273303bgryzor handler used by default to handle static content.
f072359f493a5209335799da85ac16d6a273303bgryzor Send file with HTTP headers as is.
f072359f493a5209335799da85ac16d6a273303bgryzor Treat the file as a CGI script.
f072359f493a5209335799da85ac16d6a273303bgryzor Parse as an imagemap rule file.
f072359f493a5209335799da85ac16d6a273303bgryzor Get the server's configuration information.
f072359f493a5209335799da85ac16d6a273303bgryzor Parse for server-side includes.
f072359f493a5209335799da85ac16d6a273303bgryzor Get the server's status report.
f072359f493a5209335799da85ac16d6a273303bgryzor Parse as a type map file for content negotiation.
f072359f493a5209335799da85ac16d6a273303bgryzor (<A HREF="mod/mod_negotiation.html">mod_negotiation</A>)
f072359f493a5209335799da85ac16d6a273303bgryzor<p>The following directives will cause requests for files with the
f072359f493a5209335799da85ac16d6a273303bgryzor<code>html</code> extension to trigger the launch of the
f072359f493a5209335799da85ac16d6a273303bgryzor AddHandler add-footer .html
f072359f493a5209335799da85ac16d6a273303bgryzor<p>Then the CGI script is responsible for sending the originally
f072359f493a5209335799da85ac16d6a273303bgryzorrequested document (pointed to by the <code>PATH_TRANSLATED</code>
f072359f493a5209335799da85ac16d6a273303bgryzorenvironment variable) and making whatever modifications or additions
f072359f493a5209335799da85ac16d6a273303bgryzorare desired.</p>
f072359f493a5209335799da85ac16d6a273303bgryzor<p>The following directives will enable the <code>send-as-is</code>
f072359f493a5209335799da85ac16d6a273303bgryzorhandler, which is used for files which contain their own HTTP headers.
f072359f493a5209335799da85ac16d6a273303bgryzorAll files in the <code>/web/htdocs/asis/</code> directory will be
f072359f493a5209335799da85ac16d6a273303bgryzorprocessed by the <code>send-as-is</code> handler, regardless of their
f072359f493a5209335799da85ac16d6a273303bgryzorfilename extensions.</p>
f072359f493a5209335799da85ac16d6a273303bgryzor SetHandler send-as-is
f072359f493a5209335799da85ac16d6a273303bgryzor </Directory>
f072359f493a5209335799da85ac16d6a273303bgryzor<P>In order to implement the handler features, an addition has been
f072359f493a5209335799da85ac16d6a273303bgryzormade to the <A HREF="misc/API.html">Apache API</A> that you may wish to
f072359f493a5209335799da85ac16d6a273303bgryzormake use of. Specifically, a new record has been added to the
f072359f493a5209335799da85ac16d6a273303bgryzor char *handler
f072359f493a5209335799da85ac16d6a273303bgryzor<P>If you wish to have your module engage a handler, you need only to
f072359f493a5209335799da85ac16d6a273303bgryzorset <CODE>r->handler</CODE> to the name of the handler at any time
f072359f493a5209335799da85ac16d6a273303bgryzorrequest. Handlers are implemented as they were before, albeit using
f072359f493a5209335799da85ac16d6a273303bgryzorthe handler name instead of a content type. While it is not
f072359f493a5209335799da85ac16d6a273303bgryzornecessary, the naming convention for handlers is to use a
f072359f493a5209335799da85ac16d6a273303bgryzordash-separated word, with no slashes, so as to not invade the media
f072359f493a5209335799da85ac16d6a273303bgryzortype name-space.</P>
f072359f493a5209335799da85ac16d6a273303bgryzor<!--#include virtual="footer.html" -->