httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Schaefer <>
Subject Re: libapreq file upload
Date Fri, 24 Dec 2004 20:21:01 GMT
Nicholas Studt <> writes:

> I'm working on porting to MP2 and libapreq2 (2.05 snapshot from 11-29)
> and have hit a snag with file upload.
> I am trying to convert the following construct to mp2
> my $apr = Apache::Request->new( $r, TEMP_DIR => '/tmp',
>                                 POST_MAX => 2097152 );
> my $status  = $apr->parse;
> return( 'Error: Upload File too large.' ) if ( $status );
> If I read the documentation correctly the parse call should no longer be
> needed, 

It isn't always needed, but it is often useful.  Your
example looks to be one of those situations.  $req->body_status 
doesn't induce a parse; it just reports the *current state*
of the parser.   What you want is the *final state*, so
$req->parse is the way to go.  The docs probably don't
explain that distinction well enough.

> but I am having problems trapping the case when the file upload
> is too large.

The error-reporting in libapreq2 is currently pretty crappy.
Hopefully we'll find time to improve that before the 2.05 release.

> I've tried checking body_status and arg_status but they don't seem to
> work as I would expect which is to say that body_status always returns
> 70022 and arg_status always returns 0. 

70022 translates to APR_EINIT, which means no parsing activity
has taken place yet.  In your example, it makes perfect sense to call
$req->parse, because that forces the parser to run to completion.

The only problem I can see with your code is that you aren't
able to tell what kind of error acually took place; you're just 
guessing (quite reasonably) it was an oversized upload.  That's not 
your fault, because we don't yet provide enough details for you to
know exactly what went wrong without looking at the error log.

Joe Schaefer

View raw message