Skip to content

Experimental HTTP 2 Support

Santiago Pericasgeertsen edited this page Oct 17, 2018 · 9 revisions

Introduction

Helidon 0.10.3 has experimental support for HTTP/2. This feature is turned off by default but can be enabled in an application's configuration. Enabling HTTP/2 will automatically accept, on every endpoint exposed by the application:

  1. Clients sending upgrade requests for HTTP/2
  2. Clients connecting via HTTP/2 with prior knowledge
  3. Clients sending HTTP 1.X requests

Note that in (1) the initial request is HTTP 1.X but the response, as well as every subsequent exchange, is in HTTP/2 (assuming the upgrade process is successful).

Enabling HTTP/2 Support

Experimental support for HTTP/2 is enabled in the experimental as shown next:

server:
  port: 8080
  host: 0.0.0.0
  experimental:
    enable-http2: true
    http2-max-content-length: 16384

Testing HTTP/2 Using Curl

Recent versions of the popular curl command have support for HTTP/2. The following example shows how to request an HTTP/2 upgrade:

curl --http2 http://localhost:8080/greet/Santiago

The -v (verbose) option can be used to confirm the upgrade. If prior knowledge is available that an endpoint supports HTTP/2, then the upgrade can be bypassed as follows:

curl --http2-prior-knowledge http://localhost:8080/greet/Santiago

Finally, you can verify the use of a single HTTP/2 connection for multiple requests by simply passing more than one URL as a parameter. For example:

URL=http://localhost:8080/greet/Santiago
curl --http2-prior-knowledge $URL $URL $URL

In HTTP 1.X terms, all HTTP/2 connections are always keep-alive.