Restore max-http-header-size default value support
Fix `TomcatWebServerFactoryCustomizer` to restore Spring Boot 2.0 behavior where a negative or zero `max-http-header-size` indicates that the server default should be used. See gh-14986
This commit is contained in:
parent
807743b679
commit
8b40ce14cb
|
@ -86,7 +86,7 @@ public class TomcatWebServerFactoryCustomizer implements
|
|||
propertyMapper.from(tomcatProperties::getMinSpareThreads).when(this::isPositive)
|
||||
.to((minSpareThreads) -> customizeMinThreads(factory, minSpareThreads));
|
||||
propertyMapper.from(this::determineMaxHttpHeaderSize).whenNonNull()
|
||||
.asInt(DataSize::toBytes)
|
||||
.asInt(DataSize::toBytes).when(this::isPositive)
|
||||
.to((maxHttpHeaderSize) -> customizeMaxHttpHeaderSize(factory,
|
||||
maxHttpHeaderSize));
|
||||
propertyMapper.from(tomcatProperties::getMaxSwallowSize).whenNonNull()
|
||||
|
|
|
@ -129,6 +129,22 @@ public class TomcatWebServerFactoryCustomizerTests {
|
|||
.isEqualTo(DataSize.ofKilobytes(1).toBytes()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customMaxHttpHeaderSizeIgnoredIfNegative() {
|
||||
bind("server.max-http-header-size=-1");
|
||||
customizeAndRunServer((server) -> assertThat(((AbstractHttp11Protocol<?>) server
|
||||
.getTomcat().getConnector().getProtocolHandler()).getMaxHttpHeaderSize())
|
||||
.isEqualTo(DataSize.ofKilobytes(8).toBytes()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customMaxHttpHeaderSizeIgnoredIfZero() {
|
||||
bind("server.max-http-header-size=0");
|
||||
customizeAndRunServer((server) -> assertThat(((AbstractHttp11Protocol<?>) server
|
||||
.getTomcat().getConnector().getProtocolHandler()).getMaxHttpHeaderSize())
|
||||
.isEqualTo(DataSize.ofKilobytes(8).toBytes()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
public void customMaxHttpHeaderSizeWithDeprecatedProperty() {
|
||||
|
|
Loading…
Reference in New Issue