diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java index 22c7f5169a..c917b8cd9b 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -790,7 +790,7 @@ public class ServerProperties if (maxHttpHeaderSize > 0) { customizeMaxHttpHeaderSize(factory, maxHttpHeaderSize); } - if (serverProperties.getMaxHttpPostSize() > 0) { + if (serverProperties.getMaxHttpPostSize() != 0) { customizeMaxHttpPostSize(factory, serverProperties.getMaxHttpPostSize()); } if (this.accesslog.enabled) { diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java index e581c42e7a..5325e348e5 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -445,6 +445,25 @@ public class ServerPropertiesTests { assertThat(remoteIpValve.getInternalProxies()).isEqualTo("192.168.0.1"); } + @Test + public void customTomcatDisableMaxHttpPostSize() { + Map map = new HashMap(); + map.put("server.max-http-post-size", "-1"); + bindProperties(map); + TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory(0); + this.properties.customize(container); + TomcatEmbeddedServletContainer embeddedContainer = + (TomcatEmbeddedServletContainer) container.getEmbeddedServletContainer(); + embeddedContainer.start(); + try { + assertThat(embeddedContainer.getTomcat().getConnector().getMaxPostSize()) + .isEqualTo(-1); + } + finally { + embeddedContainer.stop(); + } + } + @Test public void defaultUseForwardHeadersUndertow() throws Exception { UndertowEmbeddedServletContainerFactory container = spy(