HTTP/2 support for Liberty
Override the default HTTP/2 configuration for Servlet 3.1, Servlet 4.0 or later.
- Use the HTTP/2 protocol in Liberty
-
The HTTP/2 protocol is an optimization of the HTTP/1.1 protocol. Any endpoint can enable support for HTTP/2. However, if both endpoints in a connection do not support HTTP/2, then the HTTP/1.1 protocol is used. For a Secure Sockets Layer (SSL) connection, the Application-Layer Protocol Negotiation (ALPN) protocol is used to negotiate HTTP/2. For insecure connections, an HTTP upgrade header is used to request HTTP/2. For all connections, the client initiates the request to use HTTP/2. HTTP/2 endpoint negotiation and usage are transparent to the user.
When the Servlet 4.0 feature, or any version thereafter is enabled in Liberty, HTTP/2 is enabled by default for all secure and insecure ports. When the Servlet 3.1 feature is enabled in Liberty, the HTTP/2 protocol is disabled by default for all secure and insecure ports. To override the default settings, configure individual ports of the Liberty server to use HTTP/2.
The HTTP/2 protocol is not an option for Servlet 3.0 or earlier.
If the Servlet 4.0 feature, or any version thereafter is enabled, and we do not want to use HTTP/2 for an httpEndpoint definition, add a protocolVersion = "http/1.1" attribute to the httpEndpoint element of the Liberty server.xml configuration file.
<httpEndpoint httpPort="9080" httpsPort="9043" id="defaultHttpEndpoint" protocolVersion="http/1.1"> </httpEndpoint>
If we enable the Servlet 3.1 feature, and we want to use the HTTP/2 httpEndpoint definition, add the protocolVersion = "http/2" attribute to the httpEndpoint element of the Liberty server.xml configuration file.
<httpEndpoint httpPort="9080" httpsPort="9043" id="defaultHttpEndpoint" protocolVersion="http/2"> </httpEndpoint>
- New attributes for server.xml configuration
-
Use an optional attribute for the httpEndpoint element:
- Attribute
- protocolVersion
- Possible Values
- "http/1.1" or "http/2"
- Description
- When Servlet 4.0 or any version thereafter is enabled as a feature, set this attribute to "http/1.1" to disable HTTP/2 processing for the ports that you defined for the httpEndpoint element. When Servlet 3.1 is enabled as a feature, set this attribute to "http/2" to enable HTTP/2 processing for the ports defined for the httpEndpoint element.