private static void gracefulShutdown(Connection connection) {
        if (connection instanceof HttpConnection http1) {
            http1.getGenerator().setPersistent(false);
        } else if (connection instanceof HTTP2ServerConnection http2) {
            // Signal Jetty to do a graceful shutdown of HTTP/2 connection.
            // Graceful shutdown implies a GOAWAY frame with 'Error Code' = 'NO_ERROR' and 'Last-Stream-ID' = 2^31-1.
            // In-flight requests will be allowed to complete before connection is terminated.
            // See https://datatracker.ietf.org/doc/html/rfc9113#name-goaway for details
            http2.getSession().shutdown();
        }
    }
Implementation of a Jetty {@link Handler} that dispatches requests to JDisc's {@link com.yahoo.jdisc.handler.RequestHandler}.

@author bjorncs
container-core/src/main/java/com/yahoo/jdisc/http/server/jetty/JdiscDispatchingHandler.java