Skip to content

Commit

Permalink
[UNDERTOW-2319] Move io.undertow.multipart.minsize property to Undert…
Browse files Browse the repository at this point in the history
…owOptions
  • Loading branch information
xjusko committed Oct 16, 2024
1 parent c5281bf commit 15d2075
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
14 changes: 14 additions & 0 deletions core/src/main/java/io/undertow/UndertowOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,20 @@ public class UndertowOptions {
*/
public static final Option<Integer> MAX_RST_FRAMES_PER_WINDOW = Option.simple(UndertowOptions.class, "MAX_RST_STREAMS_PER_TIME_WINDOW", Integer.class);

/**
* Proposed default minimum size for storing content in memory before persisting to disk.
* The default value for {@code MEMORY_STORAGE_THRESHOLD} is 16 KB (16384 bytes).
*/
public static final long DEFAULT_MEMORY_STORAGE_THRESHOLD = 0x4000;

/**
* The minimum size in bytes for storing content in memory before persisting to disk. If the file content exceeds
* the specified <i>file size threshold</i> and the <i>filename</i> is not specified in the form, the content will be stored
* in memory as long as its size is less than or equal to this minimum size, after which it will be persisted to disk.
*/
public static final Option<Long> MEMORY_STORAGE_THRESHOLD = Option.simple(UndertowOptions.class, "MEMORY_STORAGE_THRESHOLD", Long.class);


/**
* Configure a read timeout for a web socket, in milliseconds. If its present it will override {@link org.xnio.Options.READ_TIMEOUT}. If the given amount of time elapses without
* a successful read taking place, the socket's next read will throw a {@link ReadTimeoutException}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class MultiPartParserDefinition implements FormParserFactory.ParserDefini
* The threshold of form field size to persist to disk.
* It takes effect only for the form fields which do not have <i>filename</i> specified.
*/
private long fieldSizeThreshold = MINSIZE;
private long fieldSizeThreshold;

public MultiPartParserDefinition() {
tempFileLocation = Paths.get(System.getProperty("java.io.tmpdir"));
Expand All @@ -101,6 +101,7 @@ public FormDataParser create(final HttpServerExchange exchange) {
UndertowLogger.REQUEST_LOGGER.debugf("Could not find boundary in multipart request with ContentType: %s, multipart data will not be available", mimeType);
return null;
}
fieldSizeThreshold = exchange.getConnection().getUndertowOptions().get(UndertowOptions.MEMORY_STORAGE_THRESHOLD, UndertowOptions.DEFAULT_MEMORY_STORAGE_THRESHOLD);
final MultiPartUploadHandler parser = new MultiPartUploadHandler(exchange, boundary, maxIndividualFileSize, fileSizeThreshold, defaultEncoding, fieldSizeThreshold);
exchange.addExchangeCompleteListener(new ExchangeCompletionListener() {
@Override
Expand Down

0 comments on commit 15d2075

Please sign in to comment.