HTTP/2 support for Liberty
Override the default HTTP/2
configuration for Servlet 4.0 and Servlet
3.1.
- Using the
HTTP/2
protocol in Liberty -
The
HTTP/2
protocol is an optimization of theHTTP/1.1
protocol. Any endpoint can enable support forHTTP/2
. However, if both endpoints in a connection do not supportHTTP/2
, then theHTTP/1.1
protocol 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/2
endpoint negotiation and usage are transparent to the user.When the Servlet 4.0 feature 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, theHTTP/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 useHTTP/2
.The
HTTP/2
protocol is not an option for Servlet 3.0 or earlier.If the Servlet 4.0 feature is enabled, and you do not want to use
HTTP/2
for anhttpEndpoint
definition, add aprotocolVersion = "http/1.1"
attribute to thehttpEndpoint
element 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/2
httpEndpoint
definition, add theprotocolVersion = "http/2"
attribute to thehttpEndpoint
element 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
httpEndpoint
element:- Attribute
protocolVersion
- Possible Values
"http/1.1"
or"http/2"
- Description
- When Servlet 4.0 is enabled as a feature, set this attribute to
"http/1.1"
to disableHTTP/2
processing for the ports that you defined for thehttpEndpoint
element. When Servlet 3.1 is enabled as a feature, set this attribute to"http/2"
to enableHTTP/2
processing for the ports that are defined for thehttpEndpoint
element.