From c662c404c581e2c6e05467ad1d7768b1027f91f8 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 17 Sep 2019 10:52:29 +0100 Subject: [PATCH] Do not enable H2C by default when using Reactor Netty Previously, Reactor Netty was the only embedded server that enabled H2C by default. This commit updates the factory to only enable HTTP/2 when SSL has also been configured, aligning it with Jetty, Tomcat, and Undertow. If H2C is required, it can be enabled using a NettyServerCustomizer: @Bean NettyServerCustomizer h2cCustomizer() { return (httpServer) -> httpServer.protocol(HttpProtocol.HTTP11, HttpProtocol.H2C); } Closes gh-17867 --- .../embedded/netty/NettyReactiveWebServerFactory.java | 9 ++------- 1 file changed, 2 insertions(+), 7 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 023762fb00..6a88a1a65f 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 @@ -161,13 +161,8 @@ public class NettyReactiveWebServerFactory extends AbstractReactiveWebServerFact } private HttpProtocol[] listProtocols() { - if (getHttp2() != null && getHttp2().isEnabled()) { - if (getSsl() != null && getSsl().isEnabled()) { - return new HttpProtocol[] { HttpProtocol.H2, HttpProtocol.HTTP11 }; - } - else { - return new HttpProtocol[] { HttpProtocol.H2C, HttpProtocol.HTTP11 }; - } + if (getHttp2() != null && getHttp2().isEnabled() && getSsl() != null && getSsl().isEnabled()) { + return new HttpProtocol[] { HttpProtocol.H2, HttpProtocol.HTTP11 }; } return new HttpProtocol[] { HttpProtocol.HTTP11 }; }