Apache2::Request UPLOAD_HOOK and mod_perl Handler

"Michael Michalowski Web.de" <[email protected]>
Newsgroups gmane.comp.apache.apreq
Message-ID <[email protected]>
hi,

 I've got a few questions about the UPLOAD_HOOK of Apache2::Request
 and the way implementing it. I'm not sure, whether this is the right
 mailinglist or not, so sorry if this is not the right one. ;-)

 I'm trying to write a Perl Class which provides a handler() function
 for mod_perl. something like that:

     package InterRed::UploadLimiter;

     use strict;
     use Digest::MD5 qw(md5_hex);
     use CGI::Cookie;
 
     sub handler
     {
         my $r = shift;
         my $transparent_hook = sub {
         my ($upload, $data, $data_len, $hook_data) = @_;
            warn "$hook_data: got $data_len bytes for " . $upload->name;
         };

         my $req = Apache2::Request->new($r,
            UPLOAD_HOOK => $transparent_hook,
         );
         $req->parse();
        
         return Apache2::Const::OK;
     }
     
     1;
     __END__

 My main goal is to register this handler in the apache and so to
 control user uploads. I want to check the uploaded filesize and
 abort the upload if it's to huge. Then I want to redirect to another
 script (with parameters) or print something out.

 Therefor I tried to register my handler like that in my apache config
 file:

        <IfModule mod_perl.c>
#               PerlFixupHandler        InterRed::UploadLimiter
#               PerlChildInitHandler    InterRed::UploadLimiter
                PerlHandler             InterRed::UploadLimiter
        </IfModule>

 As you can see, I tried different Handler types, because I'm not sure
 which one is right to handle uploads (the upload must not be started
 at this time). I want the handler to control any kind of perl cgi
 script, which sends uploads to the server.

 In case of the PerlHandler I got no error, but handler and hook are not
 fired anyway. Same using PerlChildInitHandler.
 In case of the PerlFixupHandler the client receives a 0 byte answer
 (even if their is no upload submitted). The callback $transparent_hook
 doesn't seem to be called. The handler is called in this case.

 So, what is the right Handler to register the upload hook?
 What am I doing wrong?
 Why does the client receive a 0 byte answer in case of using
 the PerlFixupHandler?
 
greetings,
Michael
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.