modperl-odd_relationship_between_apache_request_and_cgi_pm

This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.



To: Viljo Marrandi <vilts@bbz.ee>
From: Stas Bekman <stas@stason.org>
Subject: Re: form upload limit
Date: Thu, 13 Dec 2001 23:51:05 +0800

Viljo Marrandi wrote:

> Hello,
> 
> I didn't find anywhere in Net how much is browser form upload limit
> (with POST) and how much is Apache's default form data access(input)
> limit. If anyone knows where I can find this data i'd be grateful.


There is no such a limit in Apache and probably most browsers. The limit 
can be the amount of available RAM (if the file is aggregated in the 
memory) or the filesystem limits (not enough disk space, if the uploaded 
file is created on the filesystem). You can limit it within your code, 
though.


> I tested this form upload with large text and in my case only 64K went
> thru (ended up in MySQL). I saw in Apache homepage, that I could define
> POST_MAX like this:
> 
>    my $apr = Apache::Request->new($r, POST_MAX => 1024);
> 
> Err, is this 1024 bytes or kbytes?


Since CGI.pm is the base of Apache::Request (but written in Perl, 
whereas Apache::Request is written mostly in C), parts of CGI.pm's 
extensive documentation will apply for Apache::Request as well.

So if you look at CGI.pm's manpage you will see that it's in bytes:

        $CGI::POST_MAX
            If set to a non-negative integer, this variable puts a
            ceiling on the size of POSTings, in *bytes*.

            ....If CGI.pm
            detects a POST that is greater than the ceiling, it
            will immediately exit with an error message.  This
            value will affect both ordinary POSTs and multipart
            POSTs, meaning that it limits the maximum size of file
            uploads as well.  You should set this to a reasonably
            high value, such as 1 megabyte.

You are welcome to send the documentation patches to the developers of 
the Apache::Request package at apreq-dev@httpd.apache.org. This kind of 
contribution helps a lot.


> (OT - Perl basics question) Right now I define $apr this way:
> 
> $apr = Apache::Request->new( $r->is_main ? $r : $r->main );
> 
> Now how I tell $apr that its POST_MAX = 1024?


either:

my $real_r = $r->is_main ? $r : $r->main;
my $apr = Apache::Request->new($real_r, POST_MAX => 1024);

or

$apr = Apache::Request->new( ($r->is_main ? $r : $r->main),
			      POST_MAX => 1024 );


===

To: Viljo Marrandi <vilts@bbz.ee>
From: Monika <monika.s@asu.edu>
Subject: Re: form upload limit
Date: Thu, 13 Dec 2001 08:58:11 -0700 (MST)

> I didn't find anywhere in Net how much is browser form upload limit
> (with POST) and how much is Apache's default form data access(input)
> limit. If anyone knows where I can find this data i'd be grateful.

Apache's default is 750000 and it's under the directive 
LimitRequestBody 750000

>From my expirience, it is the lower boud of the size limit (that is Apache
size limit seems to overwrite size limit from POST_MAX)

As far as POST_MAX... I was using CGI::POST_MAX=1024*100, which would set the
max size to 100 kb.
It's also defind in CGI.pm

hope this helps,
Monika

> 
> I tested this form upload with large text and in my case only 64K went
> thru (ended up in MySQL). I saw in Apache homepage, that I could define
> POST_MAX like this:
> 
>    my $apr = Apache::Request->new($r, POST_MAX => 1024);
> 
> Err, is this 1024 bytes or kbytes?
> 
> (OT - Perl basics question) Right now I define $apr this way:
> 
> $apr = Apache::Request->new( $r->is_main ? $r : $r->main );
> 
> Now how I tell $apr that its POST_MAX = 1024?
> 
> Rgds,
> Viljo
> 

===

To: modperl@apache.org
From: Rob Nagler <nagler@bivio.biz>
Subject: Re: form upload limit
Date: Thu, 13 Dec 2001 08:58:43 -0700

> There is no such a limit in Apache and probably most browsers.

By default, LimitRequestBody is 0 (unlimited) in Apache.  We limit
incoming requests with this directive, so server resources aren't
consumed by excessive.  I think POST_MAX happens after the request is
already read into memory.

LimitXMLRequestBody has a default limit of 1000000.  There are other
LimitRequest* directives which limit various aspects of the header.

Rob
===

To: modperl@apache.org
From: darren chamberlain <dlc@users.sourceforge.net>
Subject: Re: form upload limit
Date: Thu, 13 Dec 2001 11:45:59 -0500

Joe Schaefer <joe+apache@sunstarsys.com> said something to this effect on 12/13/2001:
> Is this what you want
> 
>   $apr = Apache::Request->new( $r->is_main ? $r : $r->main, 
>                                POST_MAX => 1024);
> 
> ?  I don't think Apache::Request provides any Perl methods for
> culling the post_max setting from a $apr;  you'd either have to
> write some XS for that, keep track of it yourself, or lobby for
> a new feature ;)

Or you can patch libapreq-0.33/Request/Request.xs:

*** Request.xs.orig     Thu Dec 13 11:44:25 2001
--- Request.xs  Thu Dec 13 11:36:06 2001
***************
*** 356,361 ****
--- 356,375 ----
      Apache::Request req
  
  int
+ ApacheRequest_post_max(req, max=Nullsv)
+     Apache::Request req
+     SV *max;
+ 
+     CODE:
+     if (max != Nullsv) {
+       req->post_max = (int)SvIV(max);
+     }
+     RETVAL = req->post_max;
+ 
+     OUTPUT:
+     RETVAL
+ 
+ int
  ApacheRequest_parse(req)
      Apache::Request req

This will add $apr->post_max, which works in my (simplistic and
deterministic) tests.

===


the rest of The Pile (a partial mailing list archive)

doom@kzsu.stanford.edu