Skip to content

Commit 1d54dc1

Browse files
committed
Enable Undertow to use HTTP/2
1 parent 5559969 commit 1d54dc1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/DefaultServletWebServerFactoryCustomizer.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import org.springframework.boot.web.embedded.jetty.JettyServerCustomizer;
4747
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
4848
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
49+
import org.springframework.boot.web.embedded.undertow.UndertowBuilderCustomizer;
4950
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
5051
import org.springframework.boot.web.server.Http2;
5152
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
@@ -409,6 +410,8 @@ private static class UndertowCustomizer {
409410
protected static void customizeUndertow(final ServerProperties serverProperties,
410411
Environment environment, UndertowServletWebServerFactory factory) {
411412

413+
customizeUndertowHttp2(factory, serverProperties);
414+
412415
ServerProperties.Undertow undertowProperties = serverProperties.getUndertow();
413416
ServerProperties.Undertow.Accesslog accesslogProperties = undertowProperties
414417
.getAccesslog();
@@ -450,6 +453,15 @@ protected static void customizeUndertow(final ServerProperties serverProperties,
450453
.setEagerFilterInit(undertowProperties.isEagerFilterInit()));
451454
}
452455

456+
private static void customizeUndertowHttp2(UndertowServletWebServerFactory factory,
457+
ServerProperties serverProperties) {
458+
459+
Http2 http2Properties = serverProperties.getHttp2();
460+
factory.addBuilderCustomizers((UndertowBuilderCustomizer) builder -> {
461+
builder.setServerOption(UndertowOptions.ENABLE_HTTP2, http2Properties.isEnabled());
462+
});
463+
}
464+
453465
private static void customizeConnectionTimeout(
454466
UndertowServletWebServerFactory factory, final int connectionTimeout) {
455467
factory.addBuilderCustomizers((builder) -> builder.setSocketOption(

0 commit comments

Comments
 (0)