I'm trying to use libapreq2 to upload files to the server.
If i'm not wrong not all methods are available from all filters, but i've had 
poor

results trying to guess which phases allow what methods.

My program executes all the modules (except the SSI filtering) in the URI phase

(PerlTransHandler).
I need to use that phase and not the PerlResponseHandler because is the 
executed module

who returns the uri where client has to go, so i can't wait to more advanced 
phases.
And the problem is that $r->content_type returns nothing at this stage.
I've solved this problem setting the content_type in the URI module on a 
specific call

before executing the other modules, so they will be able to read the 
content-type

(multipart/form-data) (it doesn't like me, is there any other option?).

Then i am able to use libapreq2 with this mm-kind of data, and mp2 for the rest 
of

transactions (plain text).
Passing the data with a multipart/form-data <form> i try the next:

if ($apache->content_type() eq 'multipart/form-data') {
   my $mm = Apache::Request->new($apache,POST_MAX=>50000); #50k max
   my $uploads = $mm->upload();
   warn $uploads.' '.%$uploads;
   my $table = $mm->param();
   foreach (keys %$uploads) {
      $uploads->{$_}->slurp(my $temp);
      warn $temp;
      }
   foreach (keys %$table){
      $info->{query} .= $_.'='.$table->{$_}.'&';
      warn $_.' = '.$table->{$_};
      }
} else {
   if ($apache_headers->{'Content-length'} < 10000000) {
      $apache->read($info->{query},$apache_headers->{'Content-length'});
      # here there was a bug, now it runs without problems
      }
   }

While i'm able to read all text params, there are no entries in $uploads.

If i comment the first part and use the $apache->read function, i can see the 
binary data
sent so the file is rightly uploaded (i can see in firefox but not in explorer).
Why i am not catching this through libapreq upload function?
There are very few examples so i'm not sure if i'm doing what's supposed to do. 
Is there
any error in the code?
If i need to execute the libapreq functions i another phase, is there any way 
to modify
the uri in another phase? I've tested the push_handlers function but URI 
translation comes
too late and page is not found.

Apache/2.0.52 (Win32) mod_perl/1.99_17 Perl/v5.8.2
libapreq2 2.04-dev (-mod_perl-dev 1.99_15-dev)

Thanks.

---------------------------------------------------------
Esta Navidad, sé más original ¿Te atreves a enviar una postal con tu voz? 
http://greetingmania.ya.com
Ya.com ADSL Router Wi-Fi: Sólo 29,90 €/mes + IVA*. Router + Antivirus y 
firewall ¡Gratis! http://acceso.ya.com/adsl/256router

--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html

Reply via email to