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 Boysenberry Payne <bo...@humaniteque.com> on 2006/09/13 01:09:47 UTC

Setting new POST_MAX or MAX_BODY

I'm trying to raise my post maximum and keep getting this error:

[error] [client 127.0.0.1] (20014)Internal error: Content-Length  
header (959543540) exceeds configured max_body limit (67108864)

How do I set max body higher?  So far I have:

sub handler {
	my $r = shift;
	my $req = Apache2::Request->new( $r, POST_MAX => "500000000",  
MAX_BODY => "500000000" );
}
1;

What am I doing wrong?

Thanks,
Boysenberry

boysenberrys.com | habitatlife.com | selfgnosis.com


Re: Setting new POST_MAX or MAX_BODY

Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Boysenberry Payne wrote:
> I used:
> 
> APREQ2_ReadLimit 500000000
> 
> hopefully as only a temporary solution.
> 
> I need to be able to set the ReadLimit dynamically
> if at all possible.  Is it?
By default,
read_limit is initialized to APREQ_DEFAULT_READ_LIMIT

include/apreq.h:#define APREQ_DEFAULT_READ_LIMIT        (64 * 1024 * 1024)

You can change this via
 AP_INIT_TAKE1("APREQ2_ReadLimit", apreq_set_read_limit, NULL, OR_ALL,
                  "Maximum amount of data that will be fed into a parser."),

in httpd.conf

At run time, you can do change this per request like so:
in PERL:
	my $req = APR::Request::Custom->handle($pool,
                                 $query_string,
                                 $cookie_header,
                                 $parser,
                                 $read_limit,
                                 $brigade)

or:
	(standard or custom)
 	my $limit = $req->read_limit()
 	$req->read_limit($set)

see for example:
	t/response/TestApReq/request.pm
	t/response/TestAPI/module.pm

in C land:
static apr_status_t apache2_read_limit_set, apr_uint64_t bytes)
static apr_status_t apache2_read_limit_get(apreq_handle_t *handle, apr_uint64_t *bytes)

There is one small catch whether you set it via PERL or C since the C functions are glued via XS to make the PERL ones.

It is only SET if and only if  -- this particular issue was asked on the list before.

  if (ctx->read_limit > bytes && ctx->bytes_read < bytes) {
        ctx->read_limit = bytes;
        return APR_SUCCESS;
  }

The only thing that circumvents that check is the httpd.conf APREQ2_ReadLimit variable.

HTH

-- 
------------------------------------------------------------------------
Philip M. Gollucci (pgollucci@p6m7g8.com) 323.219.4708
Consultant / http://p6m7g8.net/Resume/resume.shtml
Senior Software Engineer - TicketMaster - http://ticketmaster.com
1024D/A79997FA F357 0FDD 2301 6296 690F  6A47 D55A 7172 A799 97F

"In all that I've done wrong I know I must have done something right to
deserve a hug every morning and butterfly kisses at night."
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /
 / /|_/ / // /\ \/ /_/ / /__
/_/  /_/\_, /___/\___\_\___/
       <___/

Re: Setting new POST_MAX or MAX_BODY

Posted by Boysenberry Payne <bo...@humaniteque.com>.
I used:

APREQ2_ReadLimit 500000000

hopefully as only a temporary solution.

I need to be able to set the ReadLimit dynamically
if at all possible.  Is it?

Should I have opened this thread on the mod_perl list instead?

Thanks,
Boysenberry

boysenberrys.com | habitatlife.com | selfgnosis.com

On Sep 12, 2006, at 7:13 PM, Boysenberry Payne wrote:

> I tracked the error down to a different area than I thought.
> It happens when I call $apr->param as follows:
>
> sub utilize {
>
>   my $self = shift;	
>   my $apr = APR::Request::Apache2->handle( $self->{req} ) || return;
>   return unless( int @{[ $apr->param ]} > 0 );
>   warn "test";
>   my $data;
>   foreach my $name ( $apr->param ) {
>     $self->{param_cnt}->{$name} = int @{[ $apr->param( $name ) ]};
>     my $cnt = $self->{param_cnt}->{$name};
>     if ( $cnt == 1 ) {
> 	 $data->{$name} = uri_unescape( $apr->param( $name ) );
>     } elsif ( $cnt > 1 ) {
> 	 $data->{$name} = [ $apr->param( $name ) ];
>     }
>   }
>   $self->{data} = $data;
>   return 1;
> }
>
> The problem I have is I don't know I want the max_body set high  
> until I check to
> see if the upload param is set, i.e.  I check for upload variable  
> then if set call:
>
> my $req = Apache2::Request->new( $r, POST_MAX => "500000000",  
> MAX_BODY => "500000000" );
>
> I must be going about this the wrong way.  Any suggestions what the  
> "right way" is?
>
> Thanks,
> Boysenberry
>
> boysenberrys.com | habitatlife.com | selfgnosis.com


Re: Setting new POST_MAX or MAX_BODY

Posted by Boysenberry Payne <bo...@humaniteque.com>.
I tracked the error down to a different area than I thought.
It happens when I call $apr->param as follows:

sub utilize {

   my $self = shift;	
   my $apr = APR::Request::Apache2->handle( $self->{req} ) || return;
   return unless( int @{[ $apr->param ]} > 0 );
   warn "test";
   my $data;
   foreach my $name ( $apr->param ) {
     $self->{param_cnt}->{$name} = int @{[ $apr->param( $name ) ]};
     my $cnt = $self->{param_cnt}->{$name};
     if ( $cnt == 1 ) {
	 $data->{$name} = uri_unescape( $apr->param( $name ) );
     } elsif ( $cnt > 1 ) {
	 $data->{$name} = [ $apr->param( $name ) ];
     }
   }
   $self->{data} = $data;
   return 1;
}

The problem I have is I don't know I want the max_body set high until  
I check to
see if the upload param is set, i.e.  I check for upload variable  
then if set call:

my $req = Apache2::Request->new( $r, POST_MAX => "500000000",  
MAX_BODY => "500000000" );

I must be going about this the wrong way.  Any suggestions what the  
"right way" is?

Thanks,
Boysenberry

boysenberrys.com | habitatlife.com | selfgnosis.com