You almost certainly want to use inheritance instead.
package My::Upload; sub Upload { my ($class, $apr) = @_; $class->Add($_) foreach $apr->upload; } sub Add { my ($class, $apr) = @_; ... } package My::Doohickey; use base qw/My::Upload/; sub handler ($$) { my ($class, $r) = @_; my $apr = Apache::Request->instance($r, POST_MAX => 10*1024*1024, DISABLE_UPLOADS => 0); $class->Upload($apr) if $apr->upload; ... return OK; }
Notes:
1. Using Apache::Request->instance() reuses a previously created Apache::Request object if you've created one for the current request. Only problem is that it ignores the parameters after $r after the first invocation.
2. If you start out with something like:
sub handler ($$) { my ($class, $r) = @_; my $apr = Apache::Request->instance($r, POST_MAX => 10*1024*1024, DISABLE_UPLOADS => 0); ...
That will put the module name in $class, the Apache object in $r, and an Apache::Request object in $apr.
3. If the browser is on a dialup line, that server process will wait damn near forever for the uploaded file. This would be a cheap DoS attack on your server: just do 10 MB uploads to your server until your server starts thrashing. I generally limit uploads to the smallest I can get away with, and use a proxy Apache with a smaller footprint front end to buffer the requests.
HTH
update:As I think about it, something like My::Mod::Add->handler($r) might work. But very likely it won't ... I've never tried it and I have more interesting experiments to perform.
In reply to Re: mod_perl Apache::Request vs Apache->request
by cleverett
in thread mod_perl Apache::Request vs Apache->request
by drfrog
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |