Apache2-SSI

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN


        PerlModule Apache2::SSI
        PerlOptions +GlobalRequest
        PerlSetupEnv On
        <Directory "/home/joe/www">
            Options All +Includes +ExecCGI -Indexes -MultiViews
            AllowOverride All
            SetHandler modperl
            # You can choose to set this as a response handler or a output filter, whichever works.
            # PerlResponseHandler Apache2::SSI
            PerlOutputFilterHandler Apache2::SSI
            # If you do not set this to On, path info will not work, example:
            # /path/to/file.html/path/info
            # See: <https://httpd.apache.org/docs/current/en/mod/core.html#acceptpathinfo>
            AcceptPathInfo On
            # To enable no-caching (see no_cache() in Apache2::RequestUtil:
            PerlSetVar Apache2_SSI_NO_CACHE On
            # This is required for exec cgi to work:
            # <https://httpd.apache.org/docs/current/en/mod/mod_include.html#element.exec>
            <Files ~ "\.pl$">
                SetHandler perl-script
                AcceptPathInfo On
                PerlResponseHandler ModPerl::PerlRun
                ## Even better for stable cgi scripts:
                ## PerlResponseHandler ModPerl::Registry
                ## Change this in mod_perl1 PerlSendHeader On to the following:
                ## <https://perl.apache.org/docs/2.0/user/porting/compat.html#C_PerlSendHeader_>
                PerlOptions +ParseHeaders
            </Files>
            <Files ~ "\.cgi$">
                SetHandler cgi-script
                AcceptPathInfo On
            </Files>
            # To enable debugging output in the Apache error log
            # PerlSetVar Apache2_SSI_DEBUG 3
            # To set the default echo message
            # PerlSetVar Apache2_SSI_Echomsg 
            # To Set the default error message
            # PerlSetVar Apache2_SSI_Errmsg "Oops, something went wrong"
            # To Set the default size format: bytes or abbrev
            # PerlSetVar Apache2_SSI_Sizefmt "bytes"
            # To Set the default date time format
            # PerlSetVar Apache2_SSI_Timefmt ""
            # To enable legacy mode:
            # PerlSetVar Apache2_SSI_Expression "legacy"
            # To enable trunk mode:
            # PerlSetVar Apache2_SSI_Expression "trunk"
        </Directory>

VERSION
=======

        v0.2.0

DESCRIPTION
===========

[Apache2::SSI](https://metacpan.org/pod/Apache2::SSI){.perl-module}
implements [Apache Server Side
Include](https://httpd.apache.org/docs/current/en/howto/ssi.html){.perl-module},
a.k.a. SSI, within and outside of Apache2/mod\_perl2 framework.

[Apache2::SSI](https://metacpan.org/pod/Apache2::SSI){.perl-module} is
inspired from the original work of
[Apache::SSI](https://metacpan.org/pod/Apache::SSI){.perl-module} with
the main difference that
[Apache2::SSI](https://metacpan.org/pod/Apache2::SSI){.perl-module}
works well when called from within Apache mod\_perl2 as well as when
called outside of Apache if you want to simulate
[SSI](https://httpd.apache.org/docs/current/en/howto/ssi.html){.perl-module}.

[Apache2::SSI](https://metacpan.org/pod/Apache2::SSI){.perl-module} also
implements all of Apache SSI features, including functions, encoding and
decoding and old style variables such as `${QUERY_STRING}` as well as
modern style such as `v('QUERY_STRING')` and variants such as
`%{REQUEST_URI}`.

See below details in this documentation and in the section on [\"SSI
Directives\"](#ssi-directives){.perl-module}

Under Apache mod\_perl, you would implement it like this in your
`apache2.conf` or `httpd.conf`

        <Files *.phtml>
            SetHandler modperl
            PerlOutputFilterHandler Apache2::SSI
        </Files>

This would enable
[Apache2::SSI](https://metacpan.org/pod/Apache2::SSI){.perl-module} for
files whose extension is `.phtml`. You can also limit this by location,
such as:

        <Location /some/web/path>
            <Files *.html>
                SetHandler modperl
                PerlOutputFilterHandler Apache2::SSI
            </Files>
        </Location>

In the example above, we enable it in files with extensions `.phtml`,
but you can, of course, enable it for all html by setting extension
`.html` or whatever extension you use for your html files.

As pointed out by Ken Williams, the original author of
[Apache::SSI](https://metacpan.org/pod/Apache::SSI){.perl-module}, the
benefit for using
[Apache2::SSI](https://metacpan.org/pod/Apache2::SSI){.perl-module} is:

1. You want to subclass [Apache2::SSI](https://metacpan.org/pod/Apache2::SSI){.perl-module} and have granular control on how to render ssi

:   

2. You want to \"parse the output of other mod\_perl handlers, or send the SSI output through another handler\"

:   

3. You want to imitate SSI without activating them or without using Apache (such as in command line) or within your perl/cgi script

:   

README.md  view on Meta::CPAN

in the string with \"to\".

Example:

        <!--#if expr="replace( 'John is in Tokyo', 'John', 'Jack' ) == 'Jack is in Tokyo'" -->
        This worked!
        <!--#else -->
        Nope, it failed.
        <!--#endif -->

parse\_func\_req
----------------

See [\"parse\_func\_http\"](#parse_func_http){.perl-module}

parse\_func\_reqenv
-------------------

Lookup request environment variable (as a shortcut, v can also be used
to access variables).

This is only different from
[\"parse\_func\_env\"](#parse_func_env){.perl-module} under Apache.

See [\"parse\_func\_env\"](#parse_func_env){.perl-module}

Example:

        <!--#if expr="reqenv('ProcessId') == '$$'" -->
        This worked!
        <!--#else -->
        Nope, it failed.
        <!--#endif -->

Or using the Apache SSI `v` shortcut:

        <!--#if expr="v('ProcessId') == '$$'" -->

parse\_func\_req\_novary
------------------------

Same as [\"parse\_func\_req\"](#parse_func_req){.perl-module}, but
header names will not be added to the Vary header.

parse\_func\_resp
-----------------

Get HTTP response header.

Example:

        <!--#if expr="resp('X-ProcessId') == '$$'" -->
        This worked!
        <!--#else -->
        Nope, it failed.
        <!--#endif -->

An important note here:

First, there is obviously no response header available for perl scripts
running outside of Apache2/mod\_perl2 framework.

If the script runs under mod\_perl, not all response header will be
available depending on whether you are using
[Apache2::SSI](https://metacpan.org/pod/Apache2::SSI){.perl-module} in
your Apache configuration as an output filter handler
(`PerlOutputFilterHandler`) or a response handler
(`PerlResponseHandler`).

If it is running as an output filter handler, then some headers, such as
`Content-Type` will not be available, unless they have been set by a
script in a previous phase. Only basic headers will be available. For
more information, check the Apache/mod\_perl2 documentation on each
phase.

parse\_func\_sha1
-----------------

Hash the string using SHA1, then encode the hash with hexadecimal
encoding.

Example:

        <!--#if expr="sha1('Tous les êtres humains naissent libres et égaux en dignité et en droits.') == '8c244078c64a51e8924ecf646df968094a818d59'" -->
        This worked!
        <!--#else -->
        Nope, it failed.
        <!--#endif -->

parse\_func\_tolower
--------------------

Convert string to lower case.

Example:

        <!--#if expr="tolower('Tous les êtres humains naissent libres et égaux en dignité et en droits.') == 'tous les êtres humains naissent libres et égaux en dignité et en droits.'" -->
        This worked!
        <!--#else -->
        Nope, it failed.
        <!--#endif -->

parse\_func\_toupper
--------------------

Convert string to upper case.

Example:

        <!--#if expr="toupper('Tous les êtres humains naissent libres et égaux en dignité et en droits.') == 'TOUS LES ÊTRES HUMAINS NAISSENT LIBRES ET ÉGAUX EN DIGNITÉ ET EN DROITS.'" -->
        This worked!
        <!--#else -->
        Nope, it failed.
        <!--#endif -->

parse\_func\_unbase64
---------------------

Decode base64 encoded string, return truncated string if 0x00 is found.

Example:



( run in 0.589 second using v1.01-cache-2.11-cpan-df04353d9ac )