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
This commit is contained in:
Brian Clozel
2018-02-27 23:47:35 +01:00
parent 7f85322ddd
commit 438004efe5
2 changed files with 2 additions and 15 deletions
@@ -106,8 +106,8 @@ public class NettyReactiveWebServerFactory extends AbstractReactiveWebServerFact
getSsl(), getSslStoreProvider()); getSsl(), getSslStoreProvider());
sslServerCustomizer.customize(options); sslServerCustomizer.customize(options);
} }
if (getCompression() != null && getCompression().getEnabled()) { if (getCompression() != null) {
options.compression(getCompression().getMinResponseSize()); options.compression(getCompression().getEnabled());
} }
applyCustomizers(options); applyCustomizers(options);
}).build(); }).build();
@@ -273,19 +273,6 @@ public abstract class AbstractReactiveWebServerFactoryTests {
assertResponseIsCompressed(response); 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<Void> response = client.get().exchange()
.flatMap((res) -> res.toEntity(Void.class)).block();
assertResponseIsNotCompressed(response);
}
@Test @Test
public void noCompressionForMimeType() throws Exception { public void noCompressionForMimeType() throws Exception {
Assumptions.assumeThat(getFactory()) Assumptions.assumeThat(getFactory())