httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Issac Goldstand <mar...@beamartyr.net>
Subject Re: [mp2] aborting a file upload
Date Fri, 09 Mar 2007 07:53:23 GMT
I'm not positive, but I think it's dangerous as it can screw up
pipelined requests - that's why discard_request_body exists.  I've cc-ed
dev@httpd as all the smart HTTP people hang out there :-)  and maybe one
of them can either confirm or correct that statement.

  Issac

Matt Williamson wrote:
> I wrote a filter which I think does the trick. It seems to work. In the
> filter I send end of stream (eos) if the content length is too large,
> otherwise just pass the data along. The filter is registered as a
> PerlInputFilterHandler, which according to the docs only gets called on
> the body, not the headers.
> 
> Since I am new to mod_perl, could anyone comment on whether this is a
> dangerous thing to do?
> 
> Code below 
> 
> Matt
> 
> use base qw(Apache2::Filter);
> 
> use Apache2::Const -compile => qw(OK :log);
> use APR::Const    -compile => qw(SUCCESS);
> use Apache2::RequestRec ();
> use Apache2::Log ();
> 
> use constant BUFF_LEN => 4092;
> 
> use constant CONTENT_LIMIT => 104857600;
> 
> sub handler : FilterRequestHandler {
>     my $f = shift;
>     # get the request.
>     my $r = $f->r;
>     my $contentLength = $r->headers_in->{'Content-Length'};
>     if ($contentLength > CONTENT_LIMIT) {
> 	# send an end of stream
> 	$f->seen_eos(1);
>     } else {
> 	while ($f->read(my $buffer, BUFF_LEN)) {
> 	    $f->print($buffer);
> 	}
>     }
> 
>     Apache2::Const::OK;
> } 
> 

Mime
View raw message