Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UNDERTOW-2319] Move io.undertow.multipart.minsize property to UndertowOptions #1533

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -448,6 +448,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 @@ -62,11 +62,6 @@ public class MultiPartParserDefinition implements FormParserFactory.ParserDefini


public static final String MULTIPART_FORM_DATA = "multipart/form-data";
/**
* Proposed default MINSIZE as 16 KB for content in memory before persisting to disk if file content exceeds
* {@link #fileSizeThreshold} and the <i>filename</i> is not specified in the form.
*/
private static final long MINSIZE = Long.getLong("io.undertow.multipart.minsize", 0x4000);

private Executor executor;

Expand All @@ -82,7 +77,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 +96,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
Loading