eclipse-vertx / eclipse-vertx/vert.x
Provide an option to handle form fields similarly to file uploads
- Dominant language
- Java
- Stars
- 14.7k
- Forks
- 2.1k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 28
Description
For multipart POST requests marked as `setExpectMultipart(true)`, the Vert.x policy is that POST form fields are provided as key-value `String` map when the request body is fully read, and for file uploads we register upload handlers to handle them in a streaming fashion, buffer-by-buffer.
With Vert.x <= 3.9.5, oversized attributes might cause OOM, from Vert.x 3.9.6 there is a limit on maximal form fields size; Vert.x refuses to collect large attributes as `String`s in memory. See also https://github.com/eclipse-vertx/vert.x/issues/3794
For some specific technological system we deal with, it's possible for our customers to upload large files through form fields. This might be an unfortunate usage of POST form fields designed to deal with "small HTML form inputs", but there are tools that use POST form fields to send megabytes (and more) of data.
It would be nice if there was an option that would allow us to install "form field handler" to deal with large form fields. The default may still be the strategy "form fields should be short", but a simple boolean option to handle form fields as "anonymous file uploads" would really help us.
I'm no expert on Netty, but it looks there is one "if" in `HttpPostMultipartRequestDecoder` which decides whether to collect in memory (`decodeMultipart(MultiPartStatus.FIELD)`) or to handle files (`decodeMultipart(MultiPartStatus.FILEUPLOAD)`). We need to have control on this "if" to always take the `FILEUPLOAD` path. This probably requires a small change in Netty as well to provide this control.
Contributor guide
Assessment
This issue has not been assessed yet.