You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by eps com estem <gg...@mixmail.com> on 2004/12/19 16:29:30 UTC
libapreq2 upload question
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
Re: libapreq2 upload question
Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Sun, 19 Dec 2004, eps com estem wrote:
> I'm trying to use libapreq2 to upload files to the server.
[ .. ]
> 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)
In case this is a bug in either mod_perl or libapreq2, could
you try upgrading to later versions? If you're using ppm on
Win32, these are available at
http://theoryx5.uwinnipeg.ca/ppms/
The mod_perl.ppd package here is RC1 (Release Candidate 1),
while the libapreq2.ppd package is the latest svn sources of
libapreq2 built against this mp2 version. If you had
previous versions of either of these installed via ppm, you
may have to remove them first from within the ppm shell and
then re-install them, in case ppm won't upgrade them.
--
best regards,
randy kobes
--
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
Re: libapreq2 upload question
Posted by Joe Schaefer <jo...@sunstarsys.com>.
"eps com estem" <gg...@mixmail.com> writes:
> if ($apache->content_type() eq 'multipart/form-data') {
No. $r->content_type() represents the response (outgoing) header,
not the request (incoming) header:
http://perl.apache.org/docs/2.0/api/Apache/RequestRec.html#C_content_type_
>
> While i'm able to read all text params, there are no entries in $uploads.
No clue. I'd like to help, but puzzling out the problem
from your code snippets isn't sufficient enticement. Please
post full details, including a complete package+handler with
configuration info and error-log output. Maybe it's an apreq
bug, maybe it isn't. But if I can't reproduce your problem
locally, there's not much I can do other than offer you my
sympathy.
--
Joe Schaefer
--
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