Mantis - Resin
Viewing Issue Advanced Details
6077 minor always 07-27-17 14:04 11-21-17 09:43
ferg  
ferg  
normal  
closed  
fixed  
none    
none 4.0.54  
0006077: multipart/form-data caucho.multipart.form.error
(rep by Steffen Busch)
Please fill "caucho.multipart.form.error" and "caucho.multipart.form.error.size" in case of IllegalStateException as well.


I'm trying to use the Servlet 3.0+ Capabilities of the multipart/form-data requests and looked up several Caucho resources such as:
 1: http://blog.caucho.com/2009/10/22/servlet-30-tutorial-uploading-files/ [^]
 2: http://www.caucho.com/resin-4.0/reference.xtp#multipart-form [^]


I would really like to use the two offered Request attributes as mentioned on the 2: Link to improve error messages to users.

<..>
If the upload is larger than the limit or if multipart-form processing is disabled, Resin will not parse the request and will set an error message in the "caucho.multipart.form.error" request attribute. The "caucho.multipart.form.error.size" will contain the attempted upload size.
<..>

However, the "caucho.multipart.form.error" and "caucho.multipart.form.error.size" request attributes are empty in the following two situations:


Sitation 1: IllegalStateException (caused by MultipartFormParser.java:137)

For example if a single File (Part) is processed and the Size is greater than <max-file-size>10M</max-file-size> from the Servlet's <multipart-config>

java.lang.IllegalStateException: multipart form data part 'File':'11148012' is greater then the accepted value of '10485760'
  at com.caucho.server.http.MultipartFormParser.parsePostData(MultipartFormParser.java:137)
  at com.caucho.server.http.AbstractCauchoRequest.parsePostQueryImpl(AbstractCauchoRequest.java:462)
  at com.caucho.server.http.AbstractCauchoRequest.parseQueryImpl(AbstractCauchoRequest.java:296)
  at com.caucho.server.http.AbstractCauchoRequest.getParts(AbstractCauchoRequest.java:247)



Sitation 2: IllegalStateException (caused by AbstractCauchoRequest.java:434)

For example if several files (Parts) are processed (none of them is bigger than <max-file-size> see Situation 1) but the total size is greater than <max-request-size>10M</max-request-size> from the Servlet's <multipart-config>

java.lang.IllegalStateException: multipart form data request's Content-Length '20780351' is greater then configured in @MultipartConfig.maxRequestSize value: '10485760'
  at com.caucho.server.http.AbstractCauchoRequest.parsePostQueryImpl(AbstractCauchoRequest.java:434)
  at com.caucho.server.http.AbstractCauchoRequest.parseQueryImpl(AbstractCauchoRequest.java:296)
  at com.caucho.server.http.AbstractCauchoRequest.getParts(AbstractCauchoRequest.java:247)

  
Note:
Stacktraces obtained from Caucho Resin 4.0.50


It would be great if you can fill "caucho.multipart.form.error" and "caucho.multipart.form.error.size" request attributes in both cases.

Note:
Whenever I experienced an IOException from MultipartFormParser caused by "throw formError" at least the "caucho.multipart.form.error" attribute was present and most of the time the "caucho.multipart.form.error.size" too.
For example:
 * multipart form data '{0}' too large
 * multipart form upload failed (possibly due to full disk)
 * multipart form upload failed because field '{0}' exceeds max length {1}
 * End of post before multipart-mime boundary


Notes
(0006774)
ferg   
08-02-17 14:25   
server/1655