.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. | will give a
.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
.\" expand to `' in nroff, nothing in troff, for use with C<>.
.tr \(*W-|\(bv\*(Tr
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.\"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "Apache::SSI 3"
.TH Apache::SSI 3 "2008-01-18" "perl v5.8.8" "User Contributed Perl Documentation"
.SH "NAME"
Apache::SSI \- Implement Server Side Includes in Perl
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
In httpd.conf:
.PP
.Vb 4
\& # or whatever
\& SetHandler perl-script
\& PerlHandler Apache::SSI
\&
.Ve
.PP
You may wish to subclass Apache::SSI for your own extensions. If so,
compile mod_perl with PERL_METHOD_HANDLERS=1 (so you can use object-oriented
inheritance), and create a module like this:
.PP
.Vb 3
\& package MySSI;
\& use Apache::SSI ();
\& @ISA = qw(Apache::SSI);
.Ve
.PP
.Vb 8
\& #embedded syntax:
\& #
\& sub ssi_something {
\& my($self, $attr) = @_;
\& my $cmd = $attr->{param};
\& ...
\& return $a_string;
\& }
.Ve
.PP
.Vb 1
\& Then in httpd.conf:
.Ve
.PP
.Vb 4
\&
\& SetHandler perl-script
\& PerlHandler MySSI
\&
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
Apache::SSI implements the functionality of mod_include for handling
server-parsed html documents. It runs under Apache's mod_perl.
.PP
In my mind, there are two main reasons you might want to use this module:
you can sub-class it to implement your own custom \s-1SSI\s0 directives, and/or you
can parse the output of other mod_perl handlers, or send the \s-1SSI\s0 output
through another handler (use Apache::Filter to do this).
.PP
Each \s-1SSI\s0 directive is handled by an Apache::SSI method with the prefix
\&\*(L"ssi_\*(R". For example, is handled by the ssi_printenv method.
attribute=value pairs inside the \s-1SSI\s0 tags are parsed and passed to the
method in a hash reference.
.PP
\&'Echo' directives are handled by the ssi_echo method, which delegates
lookup to methods with the prefix \*(L"echo_\*(R". For instance, is handled by the echo_DOCUMENT_NAME method.
.PP
You can customize behavior by inheriting from Apache::SSI and
overriding 'ssi_*' and 'echo_*' methods, or writing new ones.
.Sh "\s-1SSI\s0 Directives"
.IX Subsection "SSI Directives"
This module supports the same directives as mod_include. At least, that's
the goal. =) For methods listed below but not documented, please see
mod_include's online documentation at http://www.apache.org/ .
.IP "* config" 4
.IX Item "config"
.PD 0
.IP "* echo" 4
.IX Item "echo"
.IP "* exec" 4
.IX Item "exec"
.IP "* fsize" 4
.IX Item "fsize"
.IP "* flastmod" 4
.IX Item "flastmod"
.IP "* include" 4
.IX Item "include"
.IP "* printenv" 4
.IX Item "printenv"
.IP "* set" 4
.IX Item "set"
.IP "* perl" 4
.IX Item "perl"
.PD
There are two ways to call a Perl function, and two ways to supply it with
arguments. The function can be specified either as an anonymous subroutine
reference, or as the name of a function defined elsewhere:
.Sp
.Vb 2
\&
\&
.Ve
.Sp
If the 'sub' argument matches the regular expression /^\es*sub[^\ew:]/,
it is assumed to be a subroutine reference. Otherwise it's assumed to
be the name of a function. In the latter case, the string \*(L"main::\*(R"
will be prepended to the function name if the name doesn't contain
\&\*(L"::\*(R" (this forces the function to be in the main package, or a package
you specify). Note that it's a pretty bad idea to put your code in
the main package, so I only halfheartedly endorse this feature.
.Sp
In general, it will be slower to use anonymous subroutines, because
each one has to be \fIeval()\fR'ed and there is no caching. For best
results, pre-load any code you need in the parent process, then call
it by name.
.Sp
If you're calling a subroutine like \*(L"&Package::SubPack::handler\*(R", you
can omit the \*(L"handler\*(R" portion, making your directive like this:
.Sp
.Vb 1
\&
.Ve
.Sp
If you want to supply a list of arguments to the function, you use either
the \*(L"arg\*(R" or the \*(L"args\*(R" parameter:
.Sp
.Vb 3
\&
\&
\&
.Ve
.Sp
The \*(L"args\*(R" parameter will simply split on commas, meaning that currently
there's no way to embed a comma in arguments passed via the \*(L"args\*(R"
parameter. Use the \*(L"arg\*(R" parameter for this.
.Sp
If you give a key-value pair and the key is not 'sub', 'arg', 'args', or
\&'pass_request' (see below), then your routine will be passed \fBboth\fR the
key and the value. This lets you pass a hash of key-value pairs to your
function:
.Sp
.Vb 2
\&
\& Will call &holy::matrimony('groom', 'Hi', 'bride', 'Lois');
.Ve
.Sp
As of version 1.95, we pass the current Apache request object ($r) as the
first argument to the function. To turn off this behavior, give the key-value
pair 'pass_request=no', or put 'PerlSetVar SSIPerlPass_Request no' in your
server's config file.
.Sp
See \f(CW\*(C`http://perl.apache.org/src/mod_perl.html\*(C'\fR for more information on Perl
\&\s-1SSI\s0 calls.
.IP "* if" 4
.IX Item "if"
.PD 0
.IP "* elif" 4
.IX Item "elif"
.IP "* else" 4
.IX Item "else"
.IP "* endif" 4
.IX Item "endif"
.PD
These four directives can be used just like in \f(CW\*(C`mod_include\*(C'\fR, with one important
difference: the boolean expression is evaluated using Perl's \fIeval()\fR. This means
you use \f(CW\*(C`==\*(C'\fR or \f(CW\*(C`eq\*(C'\fR instead of \f(CW\*(C`=\*(C'\fR to test equality. It also means you can use
pre-loaded Perl subroutines in the conditions:
.Sp
.Vb 5
\&
\& This movie is by the Coen Brothers.
\&
\& This movie is not by the Coen Brothers.
\&
.Ve
.Sp
It can't handle very sophistocated Perl though, because it manually looks for
variables (of the form \f(CW$var\fR or ${var}, just like \f(CW\*(C`mod_include\*(C'\fR), and will get tripped
up on expressions like \f(CW$object\fR\->method or \f(CW$hash\fR{'key'}. I'll welcome any suggestions
for how to allow arbitrary Perl expressions while still filling in Apache variables.
.SH "CHAINING HANDLERS"
.IX Header "CHAINING HANDLERS"
There are two fairly simple ways for this module to exist in a stacked handler
chain. The first uses \f(CW\*(C`Apache::Filter\*(C'\fR, and your httpd.conf would look something
like this:
.PP
.Vb 9
\& PerlModule Apache::Filter
\& PerlModule Apache::SSI
\& PerlModule My::BeforeSSI
\& PerlModule My::AfterSSI
\&
\& SetHandler perl-script
\& PerlSetVar Filter On
\& PerlHandler My::BeforeSSI Apache::SSI My::AfterSSI
\&
.Ve
.PP
The \f(CW"PerlSetVar Filter On"\fR directive tells the three stacked handlers that
they should use their filtering mode. It's mandatory.
.PP
The second uses \f(CW\*(C`Apache::OutputChain\*(C'\fR, and your httpd.conf would look something
like this:
.PP
.Vb 8
\& PerlModule Apache::OutputChain
\& PerlModule Apache::SSIChain
\& PerlModule My::BeforeSSI
\& PerlModule My::AfterSSI
\&
\& SetHandler perl-script
\& PerlHandler Apache::OutputChain My::AfterSSI Apache::SSIChain My::BeforeSSI
\&
.Ve
.PP
Note that the order of handlers is reversed in the two different methods. One
reason I wrote \f(CW\*(C`Apache::Filter\*(C'\fR is to get the order to be more intuitive.
Another reason is that \f(CW\*(C`Apache::SSI\*(C'\fR itself can be used in a handler stack using
\&\f(CW\*(C`Apache::Filter\*(C'\fR, whereas it needs to be wrapped in \f(CW\*(C`Apache::SSIChain\*(C'\fR to
be used with \f(CW\*(C`Apache::OutputChain\*(C'\fR.
.PP
Please see the documentation for \f(CW\*(C`Apache::OutputChain\*(C'\fR and \f(CW\*(C`Apache::Filter\*(C'\fR
for more specific information. And look at the note in \s-1CAVEATS\s0 too.
.SH "CAVEATS"
.IX Header "CAVEATS"
* When chaining handlers via Apache::Filter, if you use
or , then Apache::SSI must be the last filter in the
chain. This is because Apache::SSI uses \f(CW$r\fR\->lookup_uri(...)\->run to include
the files, and this sends the output through C's stdout rather than Perl's
\&\s-1STDOUT\s0. Thus Apache::Filter can't catch it and filter it.
.PP
If Apache::SSI is the last filter in the chain, or if you stick to simpler \s-1SSI\s0
directives like , , etc. you'll be fine.
.PP
* Currently, the way looks for variables is
to first try \f(CW$r\fR\->subprocess_env, then try \f(CW%ENV\fR, then the five extra environment
variables mod_include supplies. Is this the correct order?
.SH "TO DO"
.IX Header "TO DO"
Revisit http://www.apache.org/docs/mod/mod_include.html and see what else
there I can implement.
.PP
It would be nice to have a \*(L"PerlSetVar ASSI_Subrequests 0|1\*(R" option that
would let you choose between executing a full-blown subrequest when
including a file, or just opening it and printing it.
.PP
I'd like to know how to use Apache::test for the real.t test.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
mod_include, \fImod_perl\fR\|(3), \fIApache\fR\|(3), \fIHTML::Embperl\fR\|(3), \fIApache::ePerl\fR\|(3),
\&\fIApache::OutputChain\fR\|(3)
.SH "AUTHOR"
.IX Header "AUTHOR"
Ken Williams ken@mathforum.org
.PP
Concept based on original version by Doug MacEachern dougm@osf.org .
Implementation different.
.SH "COPYRIGHT"
.IX Header "COPYRIGHT"
Copyright 1998 Swarthmore College. All rights reserved.
.PP
This library is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.