You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Jochen Wiedmann (JIRA)" <ji...@apache.org> on 2006/10/31 06:59:17 UTC

[jira] Resolved: (FILEUPLOAD-117) Check file upload size only if an upload limit has been imposed

     [ http://issues.apache.org/jira/browse/FILEUPLOAD-117?page=all ]

Jochen Wiedmann resolved FILEUPLOAD-117.
----------------------------------------

    Fix Version/s: 1.2
       Resolution: Fixed

Version 1.2 does no longer depend on the presence of a ContentLength.


> Check file upload size only if an upload limit has been imposed
> ---------------------------------------------------------------
>
>                 Key: FILEUPLOAD-117
>                 URL: http://issues.apache.org/jira/browse/FILEUPLOAD-117
>             Project: Commons FileUpload
>          Issue Type: Improvement
>    Affects Versions: 1.1.1
>            Reporter: Mark Vollmann
>             Fix For: 1.2
>
>
> The current implementation asks the request for the content length and exits if the stream does not know the size (i.e. -1).
> Within Bea portal this does not work because the action request always returns -1 for getContentLength.
> However, if the portal does not impose an upload limit, this hsould be ok.
> The problematic code snippet is
>         
>          int requestSize = ctx.getContentLength();
>         if (requestSize == -1) {
>             throw new UnknownSizeException(
>                 "the request was rejected because its size is unknown");
>         }
>         if (sizeMax >= 0 && requestSize > sizeMax) {
>             throw new SizeLimitExceededException(
>                 "the request was rejected because its size (" + requestSize
>                 + ") exceeds the configured maximum (" + sizeMax + ")",
>                 requestSize, sizeMax);
>         }
> This should ne rewritten to 
>         int requestSize = ctx.getContentLength();
>         if (sizeMax >= 0)
>         {
>             if (requestSize == -1) {
>                   throw new UnknownSizeException(
>                   "the request was rejected because its size is unknown");
>              }
>             if(requestSize > sizeMax) {
>             throw new SizeLimitExceededException(
>                 "the request was rejected because its size (" + requestSize
>                 + ") exceeds the configured maximum (" + sizeMax + ")",
>                 requestSize, sizeMax);
>         }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org