Hello Team,
After upgrading our project from Undertow 2.3.20 to 2.3.22, we were facing issues with the multipart max entity size:
io.undertow.server.RequestTooBigException: UT000020: Connection terminated as request was larger than 2097152
If this is not specified it will be the same as {@link #MAX_ENTITY_SIZE}.
However this does not seem to be true. We are using Spring boot and the following customizer that set MAX_ENTITY_SIZE definitely does not solve our problem for Multipart:
@Bean
public WebServerFactoryCustomizer<UndertowServletWebServerFactory>
undertowMultipartMaxEntitySizeCustomizer(ServerProperties serverProperties) {
long maxSize = serverProperties.getUndertow().getMaxHttpPostSize().toBytes();
return factory ->
factory.addBuilderCustomizers(
builder -> {
LOG.info("Applying MAX_ENTITY_SIZE={} to Undertow builder", maxSize);
builder.setServerOption(UndertowOptions.MAX_ENTITY_SIZE, maxSize);
});
}
We must set the MULTIPART_MAX_ENTITY_SIZE which then solve our problem with multipart:
@Bean
public WebServerFactoryCustomizer<UndertowServletWebServerFactory>
undertowMultipartMaxEntitySizeCustomizer(ServerProperties serverProperties) {
long maxSize = serverProperties.getUndertow().getMaxHttpPostSize().toBytes();
return factory ->
factory.addBuilderCustomizers(
builder -> {
LOG.info("Applying MULTIPART_MAX_ENTITY_SIZE={} to Undertow builder", maxSize);
builder.setServerOption(UndertowOptions.MULTIPART_MAX_ENTITY_SIZE, maxSize);
});
}
Which seems like a bug.
Regards,