Return-Path: Delivered-To: apmail-commons-dev-archive@www.apache.org Received: (qmail 92212 invoked from network); 30 Aug 2007 06:13:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 30 Aug 2007 06:13:44 -0000 Received: (qmail 41027 invoked by uid 500); 30 Aug 2007 06:13:38 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 40954 invoked by uid 500); 30 Aug 2007 06:13:37 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 40945 invoked by uid 99); 30 Aug 2007 06:13:37 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Aug 2007 23:13:37 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of jochen.wiedmann@gmail.com designates 66.249.82.228 as permitted sender) Received: from [66.249.82.228] (HELO wx-out-0506.google.com) (66.249.82.228) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Aug 2007 06:13:32 +0000 Received: by wx-out-0506.google.com with SMTP id h29so359333wxd for ; Wed, 29 Aug 2007 23:13:11 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=W1SKugIyLEpl3pgF99MjvSeT8txNCNtcuolNhYsv/8nhjVIXYR2L3GEHm93a5ZtP9aDO4lcOhTwMcr/6tDFKARJ1zcZgGMk2dxIcYEhcQ0njm70xCbRCg61lIzijUBbsItkExvykQdIG/gBvENecp/bZKR859CVJte1J+kRawZY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=dpIA3rjZFgjE8iA+UK7ZgCaVBa6rChKzqmMGyldfqgKtg7dqcG2OSOUuxLb+ac4YqDpcCvSs+X+3ld+fQ8geVDKzNVkmCIcAOcByZ9nYTcb5PnbJLqJmstDtKEmFQiPMvTIhE5QpcIEKUfvhCmpKZWoVJbT4/hl1G7zeQy0S+DA= Received: by 10.90.98.3 with SMTP id v3mr55277agb.1188454391027; Wed, 29 Aug 2007 23:13:11 -0700 (PDT) Received: by 10.90.54.9 with HTTP; Wed, 29 Aug 2007 23:13:10 -0700 (PDT) Message-ID: Date: Thu, 30 Aug 2007 08:13:10 +0200 From: "Jochen Wiedmann" To: "Jakarta Commons Developers List" Subject: Re: FileUploadBase.setFileSizeMax & MultipartStream.ItemInputStream.makeAvailable() In-Reply-To: <6BA54373-8FA1-4D46-BC8C-0E1CDCF20BC4@alum.mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <6BA54373-8FA1-4D46-BC8C-0E1CDCF20BC4@alum.mit.edu> X-Virus-Checked: Checked by ClamAV on apache.org On 8/30/07, Eric Hermanson wrote: > setFileSizeMax is apparently intended to prevent the file upload if > the file about to be uploaded is larger than a given size. However, > the exception does not get processed until AFTER the entire file is > uploaded to the server (thereby defeating the purpose of the limit). That's not the case. If you are setting this property, then the file items input stream is wrapped by an instance of LimitedInputStream. That instance raises the exception as soon as more than fileSizeMax bytes are returned to the caller. It may certainly look so, if the uploaded file is, for example, 10.5 MB and the limit is 10MB. Apart from that, it is quite possible that the exception is ignored by the browser and the browser continues to shuffle data to the server. But that's nothing we can control. I admit, that an additional improvement could be made: We might check, if the file items headers (as opposed to the request headers) contain a content-length entry, which exceeds the limit. However, I admit that this would help, because I've seen few cases where the item does contain a content-length header. Patches welcome, though. > I went into the debugger and noticed that > > MultipartStream.ItemInputStream.close() > > is calling > > MultipartStream.ItemInputStream.makeAvailable() > > and the call to InputStream.read() in that method is actually what's > causing the entirety of the oversized file upload data to be > incorrectly read. This may be the case, if you haven't read all the data before invoking the close() method. Jochen -- "Besides, manipulating elections is under penalty of law, resulting in a preventative effect against manipulating elections. The german government justifying the use of electronic voting machines and obviously believing that we don't need a police, because all illegal actions are forbidden. http://dip.bundestag.de/btd/16/051/1605194.pdf --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org