CGI-Application-Plugin-Apache
view release on metacpan or search on metacpan
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.
COMPATIBILITY
Upon using this module you completely leave behind the world of CGI.pm.
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
CGI.pm and family.
If you are trying to use this module but don't want to have to change
your previous code that uses "header_props()" or "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
"header_props()" or "header_add()" remember that it will cause a
performance hit because it will use helper routines that try and emulate
CGI.pm.
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
:)
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 CGI.pm then
you might need some extra help.
This is what CGI::Application::Plugin::Apache::Request is for. You can
make this your "query" object by setting the "CAPA_CGI_Compat" var to
"On" in your Apache config file:
PerlSetVar CAPA_CGI_Compat On
Please see that module for more documentation on what it does.
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 "MP2" option to the
"Build.PL" script.
perl ./Build.PL MP2=1
That's pretty easy, right?
AUTHOR
Michael Peters <mpeters@plusthree.com>
Thanks to Plus Three, LP (http://www.plusthree.com) for sponsoring my
work on this module
CONTRIBUTORS
The following people have contributed to this module either through
docs, code, or ideas
William McKee <william@knowmad.com>
Cees Hek <ceeshek@gmail.com>
Drew Taylor <drew@drewtaylor.com>
Ron Savage <ron@savage.net.au>
SEE ALSO
* CGI::Application
* Apache
* Apache::Request / Apache2::Request
* Apache::Cookie / Apache2::Cookie
LICENSE
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
( run in 0.622 second using v1.01-cache-2.11-cpan-b16cb0d3907 )