Add Http2 configuration properties

This commit adds a new configuration properties class for configuring
HTTP/2 protocol support.
By default, this protocol is disabled as enabling it requires several
manual changes:

* configuring a web server for proper TLS and ALPN support
* configuring a proper SSL certificate

See gh-10043
This commit is contained in:
Brian Clozel
2017-10-31 11:50:33 +01:00
parent 7f58db7d0e
commit 58db841c8f
7 changed files with 71 additions and 0 deletions

View File

@@ -31,6 +31,7 @@ import java.util.TimeZone;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
import org.springframework.boot.web.server.Compression;
import org.springframework.boot.web.server.Http2;
import org.springframework.boot.web.server.Ssl;
import org.springframework.boot.web.servlet.server.Jsp;
import org.springframework.util.Assert;
@@ -102,6 +103,9 @@ public class ServerProperties {
@NestedConfigurationProperty
private Compression compression = new Compression();
@NestedConfigurationProperty
private Http2 http2 = new Http2();
private Servlet servlet = new Servlet();
private final Tomcat tomcat = new Tomcat();
@@ -190,6 +194,10 @@ public class ServerProperties {
return this.compression;
}
public Http2 getHttp2() {
return this.http2;
}
public Servlet getServlet() {
return this.servlet;
}

View File

@@ -55,6 +55,9 @@ public class DefaultReactiveWebServerCustomizer implements
if (this.serverProperties.getCompression() != null) {
server.setCompression(this.serverProperties.getCompression());
}
if (this.serverProperties.getHttp2() != null) {
server.setHttp2(this.serverProperties.getHttp2());
}
}
}

View File

@@ -120,6 +120,9 @@ public class DefaultServletWebServerFactoryCustomizer
if (this.serverProperties.getCompression() != null) {
factory.setCompression(this.serverProperties.getCompression());
}
if (this.serverProperties.getHttp2() != null) {
factory.setHttp2(this.serverProperties.getHttp2());
}
factory.setServerHeader(this.serverProperties.getServerHeader());
if (factory instanceof TomcatServletWebServerFactory) {
TomcatCustomizer.customizeTomcat(this.serverProperties, this.environment,