| 
29 | 29 | import org.apache.coyote.AbstractProtocol;  | 
30 | 30 | import org.apache.coyote.ProtocolHandler;  | 
31 | 31 | import org.apache.coyote.http11.AbstractHttp11Protocol;  | 
 | 32 | +import org.apache.coyote.http2.Http2Protocol;  | 
32 | 33 | import org.eclipse.jetty.server.AbstractConnector;  | 
33 | 34 | import org.eclipse.jetty.server.ConnectionFactory;  | 
34 | 35 | import org.eclipse.jetty.server.Handler;  | 
 | 
46 | 47 | import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;  | 
47 | 48 | import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;  | 
48 | 49 | import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;  | 
 | 50 | +import org.springframework.boot.web.server.Http2;  | 
49 | 51 | import org.springframework.boot.web.server.WebServerFactoryCustomizer;  | 
50 | 52 | import org.springframework.boot.web.servlet.ServletContextInitializer;  | 
51 | 53 | import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;  | 
@@ -213,6 +215,8 @@ private static class TomcatCustomizer {  | 
213 | 215 | 		public static void customizeTomcat(ServerProperties serverProperties,  | 
214 | 216 | 				Environment environment, TomcatServletWebServerFactory factory) {  | 
215 | 217 | 
 
  | 
 | 218 | +			customizeTomcatHttp2(factory, serverProperties);  | 
 | 219 | + | 
216 | 220 | 			ServerProperties.Tomcat tomcatProperties = serverProperties.getTomcat();  | 
217 | 221 | 			if (tomcatProperties.getBasedir() != null) {  | 
218 | 222 | 				factory.setBaseDirectory(tomcatProperties.getBasedir());  | 
@@ -261,6 +265,20 @@ public static void customizeTomcat(ServerProperties serverProperties,  | 
261 | 265 | 			}  | 
262 | 266 | 		}  | 
263 | 267 | 
 
  | 
 | 268 | +		private static void customizeTomcatHttp2(TomcatServletWebServerFactory factory,  | 
 | 269 | +				ServerProperties serverProperties) {  | 
 | 270 | + | 
 | 271 | +			Http2 http2Properties = serverProperties.getHttp2();  | 
 | 272 | + | 
 | 273 | +			if (http2Properties.isEnabled()) {  | 
 | 274 | +				enableTomcatHttp2(factory);  | 
 | 275 | +			}  | 
 | 276 | +		}  | 
 | 277 | + | 
 | 278 | +		private static void enableTomcatHttp2(TomcatServletWebServerFactory factory) {  | 
 | 279 | +			factory.addConnectorCustomizers(connector -> connector.addUpgradeProtocol(new Http2Protocol()));  | 
 | 280 | +		}  | 
 | 281 | + | 
264 | 282 | 		private static void customizeAcceptCount(TomcatServletWebServerFactory factory,  | 
265 | 283 | 				final int acceptCount) {  | 
266 | 284 | 			factory.addConnectorCustomizers((connector) -> {  | 
 | 
0 commit comments