commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Yandell (JIRA)" <j...@apache.org>
Subject [jira] Commented: (FILEUPLOAD-117) Check file upload size only if an upload limit has been imposed
Date Mon, 30 Oct 2006 23:57:20 GMT
    [ http://issues.apache.org/jira/browse/FILEUPLOAD-117?page=comments#action_12445737 ] 
            
Henri Yandell commented on FILEUPLOAD-117:
------------------------------------------

Though I'd ping this on the list - anyone have any thoughts on this? Seems pretty simple.

(repeating this after finding out that fileupload notifications were turned off)

> 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
>
> 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


Mime
View raw message