CGI-Application-Plugin-Apache
view release on metacpan or search on metacpan
lib/CGI/Application/Plugin/Apache.pm view on Meta::CPAN
);
$cookie->bake();
=head2 Redirects
You can still do the following to perform an HTTP redirect
$self->header_props( uri => $some_url);
$self->header_type('redirect');
return '';
But now we encourage you to do the following
$self->query->header_out(Location => $some_url);
$self->query->status(REDIRECT);
return '';
But it's really up to you.
=head1 COMPATIBILITY
Upon using this module you completely leave behind the world of L<CGI.pm|CGI>. Don't look back or
you might turn into a pillar of salt. You will have to look at and read the docs of the Apache::*
modules. But don't worry, they are really easy to use and were designed to mimic the interface
of L<CGI.pm|CGI> and family.
If you are trying to use this module but don't want to have to change your previous code that
uses C<< header_props() >> or C<< header_add() >> then we try to help you out by being as CGI
compatible as we can, but it is always better to use the mod_perl api. If you still want to use
C<< header_props() >> or C<< header_add() >> remember that it will cause a performance hit because
it will use helper routines that try and emulate L<CGI.pm|CGI>.
If you wish to write code that performs well in both environments, you can check the $ENV{MOD_PERL}
environment setting and branch accordingly. For example, to set a cookie:
if ($ENV{MOD_PERL}) {
require Apache::Cookie;
$cookie = Apache::Cookie->new(
$q,
-name => 'favorite',
-value => 'chocolate chip',
-expires => '+2h',
);
$cookie->bake;
}
else {
$cookie = $self->query->cookie(
-name => 'favorite',
-value => 'chocolate chip',
-expires => '+2h',
);
$webapp->header_add(-cookie => [$cookie]);
}
If for some reason you are using this plugin in a non-mod_perl environment, it will try to
do the right thing by simply doing nothing :)
=head2 CGI::Application::Plugin::Apache::Request
Sometimes the default compatability is not enough. For instance, if you are using
plugins that use the cookies or upload features of L<CGI.pm|CGI> then you might
need some extra help.
This is what L<CGI::Application::Plugin::Apache::Request> is for. You can make this
your C<query> object by setting the C<CAPA_CGI_Compat> var to C<On> in your Apache
config file:
PerlSetVar CAPA_CGI_Compat On
Please see that module for more documentation on what it does.
=head1 INSTALLATION
This module is designed to function equally under mod_perl 1.x and mod_perl 2.x. The only real
issue comes during the installation and testing phase. In order to track dependencies, etc we
need to know which version you are trying to install this for. By default we assume mod_perl 1.x
unless we find mod_perl 2 installed on your system.
If you want to change this, you simple pass a C<< MP2 >> option to the C<< Build.PL >> script.
perl ./Build.PL MP2=1
That's pretty easy, right?
=head1 AUTHOR
Michael Peters <mpeters@plusthree.com>
Thanks to Plus Three, LP (http://www.plusthree.com) for sponsoring my work on this module
=head1 CONTRIBUTORS
The following people have contributed to this module either through docs, code, or ideas
=over
=item William McKee <william@knowmad.com>
=item Cees Hek <ceeshek@gmail.com>
=item Drew Taylor <drew@drewtaylor.com>
=item Ron Savage <ron@savage.net.au>
=back
=head1 SEE ALSO
=over 8
=item * L<CGI::Application>
=item * L<Apache>
=item * L<Apache::Request> / L<Apache2::Request>
=item * L<Apache::Cookie> / L<Apache2::Cookie>
=back
=head1 LICENSE
( run in 1.015 second using v1.01-cache-2.11-cpan-b16cb0d3907 )