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