You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apreq-dev@httpd.apache.org by Andy Grundman <an...@hybridized.org> on 2005/04/16 18:18:56 UTC

Status of uploads in 2.05-dev?

Hi guys,

I saw this in the 2.05-dev changelog:
- C, Perl API [joes]
   Several upload-related bugfixes:
    1) apreq_upload and apreq_uploads did not search the full body table,

I'm currently using 2.04 and trying to handle multiple upload fields in 
a single form, and also more than one upload field with the same 
parameter name.  They both appear to be broken.  Can you confirm if this 
is broken in 2.04 and if it will be fixed in 2.05?  Is my problem 
related to the above change?  Maybe I'm just doing something wrong?

This code doesn't work:
for my $field ( $req->upload ) {
   for my $upload ( $req->upload($field) ) {
     my $size = $upload->size;
     # etc.
   }
}

The above code will only return the first file field, and then only if 
it's the first field in the form.  $req->upload($field) always works but 
only if you supply all the form parameters manually. 
$req->upload($field) does NOT work to pull back multiple file fields 
using the same name, it only gets the first one.

Thanks,
--
Andy Grundman

Re: Status of uploads in 2.05-dev?

Posted by Andy Grundman <an...@hybridized.org>.
Joe Schaefer wrote:
> Andy Grundman <an...@hybridized.org> writes:
> 
> 
>>Although nothing appears to have changed on my end, both upload fields
>>appear to now be working for some reason(?!)  However, the param_class
>>error is still occurring.
> 
> 
> Hmm, see if this patch (against the multi-env branch)
> helps with the param_class error:
> 
> Index: glue/perl/lib/Apache2/Upload.pm
> ===================================================================
> --- glue/perl/lib/Apache2/Upload.pm	(revision 161540)
> +++ glue/perl/lib/Apache2/Upload.pm	(working copy)
> @@ -7,11 +7,10 @@
>  }
>  sub Apache2::Request::upload {
>      my $req = shift;
> -    my $body = $req->body;
> +    my $body = $req->body or return;
>      $body->param_class(__PACKAGE__);
> -    my @uploads;
>      if (@_) {
> -        @uploads = grep $_->upload, $body->get(@_);
> +        my @uploads = grep $_->upload, $body->get(@_);
>          return wantarray ? @uploads : $uploads[0];
>      }
>  
> 

You were right about the body; we didn't have a proper body set in the 
request.  That's just been added and now everything works great!  Our 
test suite fully passes on RC5/2.05-dev.

-Andy

Re: Status of uploads in 2.05-dev?

Posted by Joe Schaefer <jo...@sunstarsys.com>.
Andy Grundman <an...@hybridized.org> writes:

> Although nothing appears to have changed on my end, both upload fields
> appear to now be working for some reason(?!)  However, the param_class
> error is still occurring.

Hmm, see if this patch (against the multi-env branch)
helps with the param_class error:

Index: glue/perl/lib/Apache2/Upload.pm
===================================================================
--- glue/perl/lib/Apache2/Upload.pm	(revision 161540)
+++ glue/perl/lib/Apache2/Upload.pm	(working copy)
@@ -7,11 +7,10 @@
 }
 sub Apache2::Request::upload {
     my $req = shift;
-    my $body = $req->body;
+    my $body = $req->body or return;
     $body->param_class(__PACKAGE__);
-    my @uploads;
     if (@_) {
-        @uploads = grep $_->upload, $body->get(@_);
+        my @uploads = grep $_->upload, $body->get(@_);
         return wantarray ? @uploads : $uploads[0];
     }
 

-- 
Joe Schaefer


Re: Status of uploads in 2.05-dev?

Posted by Andy Grundman <an...@hybridized.org>.
Joe Schaefer wrote:
> Andy Grundman <an...@hybridized.org> writes:
> 
> 
>>This is the problem I was having yesterday related to the Upload
>>module: 
>>
>>Can't call method "param_class" on an undefined value at
>>/usr/local/lib/perl/5.8.4/Apache2/Upload.pm line 11."
>>
>>This happens when calling:
>>for my $field ( $req->upload ) {
> 
> 
> Thanks!  Can you provide more info on the nature of 
> the request?  The error message you're seeing comes 
> from a successful request that has no body (according 
> to apreq).  Was it a POST? If so, what was the request's 
> Content-Type header?

I am doing a POST using a text field and 2 upload fields with different 
names.  I'm working on Catalyst support for RC5, and I attached our full 
request object.  Content-Type is:
multipart/form-data; boundary=---------------------------41184676334

Although nothing appears to have changed on my end, both upload fields 
appear to now be working for some reason(?!)  However, the param_class 
error is still occurring.

> If that doesn't lead anywhere, try setting the server's 
> LogLevel to Debug and look for mod_apreq-related messages.

I set LogLevel to Debug but it did not produce any mod_apreq messages, 
only this 1 line:
[debug] filter.c(357): [client 192.168.100.60] prefetching 65536 bytes

-Andy

Re: Status of uploads in 2.05-dev?

Posted by Joe Schaefer <jo...@sunstarsys.com>.
Andy Grundman <an...@hybridized.org> writes:

> This is the problem I was having yesterday related to the Upload
> module: 
>
> Can't call method "param_class" on an undefined value at
> /usr/local/lib/perl/5.8.4/Apache2/Upload.pm line 11."
>
> This happens when calling:
> for my $field ( $req->upload ) {

Thanks!  Can you provide more info on the nature of 
the request?  The error message you're seeing comes 
from a successful request that has no body (according 
to apreq).  Was it a POST? If so, what was the request's 
Content-Type header?

If that doesn't lead anywhere, try setting the server's 
LogLevel to Debug and look for mod_apreq-related messages.

-- 
Joe Schaefer


Re: Status of uploads in 2.05-dev?

Posted by Andy Grundman <an...@hybridized.org>.
Joe Schaefer wrote:
> Keep in mind that the installation process for mod_apreq
> has changed: you need to remove mod_apreq.so and
> s/mod_apreq.so/mod_apreq2.so/ in your server's config.
> 
> If that solves your problem, let us know so we can vote
> on moving multi-env into trunk asap.

This is the problem I was having yesterday related to the Upload module:

Can't call method "param_class" on an undefined value at 
/usr/local/lib/perl/5.8.4/Apache2/Upload.pm line 11."

This happens when calling:
for my $field ( $req->upload ) {

-Andy

Re: Status of uploads in 2.05-dev?

Posted by Joe Schaefer <jo...@sunstarsys.com>.
Andy Grundman <an...@hybridized.org> writes:

> Joe Schaefer wrote:
>> It should work with the multi-env branch; if not please report it.
>>
>
> Thanks Joe.  I tried RC5 + multi-env yesterday, but uploads completely
> crashed out I think.  I'll keep up with the tree and see how it goes.

Keep in mind that the installation process for mod_apreq
has changed: you need to remove mod_apreq.so and
s/mod_apreq.so/mod_apreq2.so/ in your server's config.

If that solves your problem, let us know so we can vote
on moving multi-env into trunk asap.

-- 
Joe Schaefer


Re: Status of uploads in 2.05-dev?

Posted by Andy Grundman <an...@hybridized.org>.
Joe Schaefer wrote:
> It should work with the multi-env branch; if not please report it.
> 

Thanks Joe.  I tried RC5 + multi-env yesterday, but uploads completely 
crashed out I think.  I'll keep up with the tree and see how it goes.

-Andy

Re: Status of uploads in 2.05-dev?

Posted by Joe Schaefer <jo...@sunstarsys.com>.
Andy Grundman <an...@hybridized.org> writes:

> Hi guys,
>
> I saw this in the 2.05-dev changelog:
> - C, Perl API [joes]
>    Several upload-related bugfixes:
>     1) apreq_upload and apreq_uploads did not search the full body table,
>
> I'm currently using 2.04 and trying to handle multiple upload fields
> in a single form, and also more than one upload field with the same
> parameter name.  They both appear to be broken.  Can you confirm if
> this is broken in 2.04 and if it will be fixed in 2.05? 

It is broken in 2.04-dev and we hope that it's now fixed in the 
multi-env branch (which will be the basis for the 2.05-dev release).

> Is my problem related to the above change?  Maybe I'm just doing
> something wrong?
>
> This code doesn't work:
> for my $field ( $req->upload ) {
>    for my $upload ( $req->upload($field) ) {
>      my $size = $upload->size;
>      # etc.
>    }
> }

It should work with the multi-env branch; if not please report it.

-- 
Joe Schaefer