Return-Path: Delivered-To: apmail-perl-modperl-archive@www.apache.org Received: (qmail 87628 invoked from network); 9 Mar 2007 07:54:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Mar 2007 07:54:08 -0000 Received: (qmail 73605 invoked by uid 500); 9 Mar 2007 07:54:05 -0000 Delivered-To: apmail-perl-modperl-archive@perl.apache.org Received: (qmail 73553 invoked by uid 500); 9 Mar 2007 07:54:05 -0000 Mailing-List: contact modperl-help@perl.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list modperl@perl.apache.org Received: (qmail 73532 invoked by uid 99); 9 Mar 2007 07:54:05 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Mar 2007 23:54:05 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (herse.apache.org: local policy) Received: from [199.203.54.245] (HELO vl654.host245.netvision.net.il) (199.203.54.245) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Mar 2007 23:53:53 -0800 Received: from [192.168.2.115] (bzq-82-81-94-105.red.bezeqint.net [82.81.94.105]) (authenticated bits=0) by mail1.mirimar.net (8.13.4/8.13.4/Debian-3sarge3) with ESMTP id l297rOUR010964 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 9 Mar 2007 09:53:26 +0200 Message-ID: <45F11273.8090207@beamartyr.net> Date: Fri, 09 Mar 2007 09:53:23 +0200 From: Issac Goldstand Organization: Mirimar Networks User-Agent: Thunderbird 1.5.0.9 (Windows/20061207) MIME-Version: 1.0 To: Matt Williamson CC: modperl@perl.apache.org, dev@httpd.apache.org Subject: Re: [mp2] aborting a file upload References: <45ED2E7A.7060605@beamartyr.net> In-Reply-To: X-Enigmail-Version: 0.94.2.0 OpenPGP: url=http://www.beamartyr.net/pubkey.asc Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV 0.90.1/2784/Fri Mar 9 08:22:49 2007 on hector.mirimar.net X-Virus-Status: Clean X-Virus-Checked: Checked by ClamAV on apache.org 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; > } >