Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

Latest commit

 

History

History
61 lines (40 loc) · 1.49 KB

File metadata and controls

61 lines (40 loc) · 1.49 KB

http/2

HTTP/2.0 is supported across the available server implementations. To enable HTTP/2.0 you need to set these properties:

server.http2.enabled = true

application.securePort = 8443

Or programmatically like:

{
  // HTTP/2.0 clear text (a.k.a h2c)
  http2();

  // HTTP/2.0 over TLS
  securePort(8443);

  get("/", req -> req.protocol());
}

Browsers don't support H2C (H2 clear text) which is why you need to configure HTTPS as well.

At bootstrap time you will see a +h2 flag that indicates that HTTP/2.0 is enabled:

   http://localhost:8080/ +h2
   https://localhost:8443/ +h2

Some servers require special configuration (besides HTTPS). So it's always good practice to check the HTTP/2.0 section of the server implementation to learn more about current support, limitations and/or configuration steps.

server push

Server push is supported via Request.push:

{
  // HTTP/2.0 clear text (a.k.a h2c)
  http2();

  // HTTP/2.0 over TLS
  securePort(8443);

  assets("/js/**");

  get("/", req -> {

    req.push("/js/home.js");

    return Results.html("home");
  });
}

When the browser requests the home page, we will send the /js/home.js resource as well!

That's all, but keep in mind that each server implementation might require some extra configuration steps to work, please check out the server documentation for more details.