HTTP/2 Support

HTTP/2 is supported for Java 9 and above. It is off by default, but can be turned on with the Http2ConfigBuilder class. The http2EnabledIfAvailable() method can be used to detect if Java 9 or later is in use, in which case it will be enabled.

public class Http2Example {
    public static void main(String[] args) {
        MuServer server = httpsServer()
            .addHandler(Method.GET, "/", (req, resp, pp) -> {
                resp.write("The HTTP protocol is " + req.protocol());
        System.out.println("Server started at " + server.uri());
(see full file)

To see which connections are using HTTP/2 or HTTP/1.1 you can access the connection info exposed by Mu Server.

Note that HTTP/2 is only supported on HTTPS.