CGI-Application-Plugin-Apache
view release on metacpan or search on metacpan
1.01
- Fixed lots of compatability problems with mod_perl 2 and Apache2::Request
1.00
- fixed misuage of Apache2::RequestUtil
0.13
- fixed warning about unitialized ENV var
0.12
- minor bug fixes in the compatability layer for cookies and uploads
- added docs mentioning CPAP_CGI_Compat and linking to
CGI::Application::Plugin::Apache::Request
0.11
- fixed small bug dealing with testing of header props
- Added more tests
0.10 ()
- Added CGI::Application::Plugin::Apache::Request wrapper around
Apache::Request for some CGI.pm compatability
);
$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.
lib/CGI/Application/Plugin/Apache.pm view on Meta::CPAN
);
$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.
lib/CGI/Application/Plugin/Apache/Request.pm view on Meta::CPAN
$value = HTML::GenerateUtil::escape_html($value,
(
$HTML::GenerateUtil::EH_LFTOBR
| $HTML::GenerateUtil::EH_SPTONBSP
| $HTML::GenerateUtil::EH_LEAVEKNOWN
)
);
return $value;
}
=item upload()
=cut
sub upload {
my ($self, $file) = @_;
# if they want a specific one, then lets give them the file handle
if( $file ) {
my $upload = $self->SUPER::upload($file);
if( $upload ) {
return $upload->fh();
} else {
return;
}
# else they want them all
} else {
my @files = $self->SUPER::upload();
@files = map { $self->SUPER::upload($_)->fh() } @files;
return @files;
}
}
1;
__END__
=item
lib/CGI/Application/Plugin/Apache2/Request.pm view on Meta::CPAN
$value = HTML::GenerateUtil::escape_html($value,
(
$HTML::GenerateUtil::EH_LFTOBR
| $HTML::GenerateUtil::EH_SPTONBSP
| $HTML::GenerateUtil::EH_LEAVEKNOWN
)
);
return $value;
}
=item upload()
=cut
sub upload {
my ($self, $file) = @_;
# if they want a specific one, then lets give them the file handle
if( $file ) {
my $upload = $self->SUPER::upload($file);
if( $upload ) {
return $upload->fh();
} else {
return;
}
# else they want them all
} else {
my @files = $self->SUPER::upload();
@files = map { $self->SUPER::upload($_)->fh() } @files;
return @files;
}
}
1;
__END__
=item
t/02-cgi_compat.t view on Meta::CPAN
# delete_all()
{
$response = GET '/cgi_compat?rm=delete_all&aa=foo&bb=bar';
ok($response->is_success);
$content = $response->content();
ok($content =~ /in runmode delete/);
ok($content =~ /aa= bb=/);
}
# 30..32
# upload()
{
my ($scheme, $addr, $port, $serverroot) = Apache::Test::vars(qw(scheme remote_addr port serverroot));
my $form = HTML::Form->parse(
qq(
<form action="/cgi_compat" method="post" enctype="multipart/form-data">
<input type="hidden" name="rm" value="upload">
<input type="file" name="test_file">
</form>
),
"$scheme://$addr:$port"
);
$form->value(test_file => catfile($serverroot, '02-cgi_compat.t'));
my $request = $form->make_request();
$response = LWP::UserAgent->new()->request($form->make_request);
$content = $response->content();
ok($content =~ /in runmode upload/);
ok($content =~ /file_name = .*cgi_compat\.t/);
ok($content =~ /file_handle = (Apache::Upload=)?GLOB/);
}
t/lib/ApachePlugin/CGI_compat.pm view on Meta::CPAN
$self->start_mode('header');
$self->run_modes([qw(
query_obj
cookie_set
cookie_get
dump
vars
escape
delete
delete_all
upload
)]);
}
sub query_obj {
my $self = shift;
return $content
. "<h3>Im in runmode query_obj</h3>"
. "obj is " . ref($self->query);
}
t/lib/ApachePlugin/CGI_compat.pm view on Meta::CPAN
sub delete_all {
my $self = shift;
my $query = $self->query;
$query->delete_all();
return $content
. "<h3>Im in runmode delete</h3>"
. "aa=" . ($query->param('aa') || '') . ' '
. "bb=" . ($query->param('bb') || '');
}
sub upload {
my $self = shift;
my $query = $self->query;
my $file_name = $query->param('test_file');
my $fh = $query->upload('test_file');
return $content
. "<h3>Im in runmode upload</h3>"
. "file_name = $file_name"
. "file_handle = $fh"
}
1;
( run in 2.665 seconds using v1.01-cache-2.11-cpan-b16cb0d3907 )