From 438004efe5453f825e3aae2de8e06f6fcaf0c261 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Tue, 27 Feb 2018 23:47:35 +0100 Subject: [PATCH] Simplify HTTP compression support for Reactor Netty This commit simplifies the HTTP compression configuration for Reactor Netty servers. Also, this commit removes a test for the `server.compression.min-response-size` support, as this is only supported when the HTTP response contains a `Content-Length` header. Since most Spring WebFlux responses are using `Transfer-Encoding: chunked`, we should not test for that case. See gh-12268 --- .../netty/NettyReactiveWebServerFactory.java | 4 ++-- .../AbstractReactiveWebServerFactoryTests.java | 13 ------------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/NettyReactiveWebServerFactory.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/NettyReactiveWebServerFactory.java index fb33f5ac42b..4d805bb118b 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/NettyReactiveWebServerFactory.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/NettyReactiveWebServerFactory.java @@ -106,8 +106,8 @@ public class NettyReactiveWebServerFactory extends AbstractReactiveWebServerFact getSsl(), getSslStoreProvider()); sslServerCustomizer.customize(options); } - if (getCompression() != null && getCompression().getEnabled()) { - options.compression(getCompression().getMinResponseSize()); + if (getCompression() != null) { + options.compression(getCompression().getEnabled()); } applyCustomizers(options); }).build(); diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/server/AbstractReactiveWebServerFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/server/AbstractReactiveWebServerFactoryTests.java index b88a4c51f4a..6a51c775e5c 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/server/AbstractReactiveWebServerFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/reactive/server/AbstractReactiveWebServerFactoryTests.java @@ -273,19 +273,6 @@ public abstract class AbstractReactiveWebServerFactoryTests { assertResponseIsCompressed(response); } - @Test - public void noCompressionForSmallResponse() throws Exception { - Assumptions.assumeThat(getFactory()) - .isInstanceOf(NettyReactiveWebServerFactory.class); - Compression compression = new Compression(); - compression.setEnabled(true); - compression.setMinResponseSize(3001); - WebClient client = prepareCompressionTest(compression); - ResponseEntity response = client.get().exchange() - .flatMap((res) -> res.toEntity(Void.class)).block(); - assertResponseIsNotCompressed(response); - } - @Test public void noCompressionForMimeType() throws Exception { Assumptions.assumeThat(getFactory())