Skip to content

Commit 2464d16

Browse files
committed
Enable Undertow to use HTTP/2
1 parent 0dcc707 commit 2464d16

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
@@ -47,6 +47,7 @@
4747
import org.springframework.boot.web.embedded.jetty.JettyServerCustomizer;
4848
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
4949
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
50+
import org.springframework.boot.web.embedded.undertow.UndertowBuilderCustomizer;
5051
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
5152
import org.springframework.boot.web.server.Http2;
5253
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
@@ -415,6 +416,8 @@ private static class UndertowCustomizer {
415416
protected static void customizeUndertow(final ServerProperties serverProperties,
416417
Environment environment, UndertowServletWebServerFactory factory) {
417418

419+
customizeUndertowHttp2(factory, serverProperties);
420+
418421
ServerProperties.Undertow undertowProperties = serverProperties.getUndertow();
419422
ServerProperties.Undertow.Accesslog accesslogProperties = undertowProperties
420423
.getAccesslog();
@@ -456,6 +459,15 @@ protected static void customizeUndertow(final ServerProperties serverProperties,
456459
.setEagerFilterInit(undertowProperties.isEagerFilterInit()));
457460
}
458461

462+
private static void customizeUndertowHttp2(UndertowServletWebServerFactory factory,
463+
ServerProperties serverProperties) {
464+
465+
Http2 http2Properties = serverProperties.getHttp2();
466+
factory.addBuilderCustomizers((UndertowBuilderCustomizer) builder -> {
467+
builder.setServerOption(UndertowOptions.ENABLE_HTTP2, http2Properties.isEnabled());
468+
});
469+
}
470+
459471
private static void customizeConnectionTimeout(
460472
UndertowServletWebServerFactory factory, final int connectionTimeout) {
461473
factory.addBuilderCustomizers((builder) -> builder.setSocketOption(

0 commit comments

Comments
 (0)