private WebSocketUpgradeResult upgradeHttp2(ServiceRequestContext ctx, HttpRequest req) throws Exception {
        if (!ctx.sessionProtocol().isExplicitHttp2()) {
            final HttpResponse fallbackResponse =
                    failOrFallback(ctx, req, () -> HttpResponse.of(HttpStatus.METHOD_NOT_ALLOWED));
            return WebSocketUpgradeResult.ofFailure(fallbackResponse);
        }
        final RequestHeaders headers = req.headers();
        if (!isHttp2WebSocketUpgradeRequest(headers)) {
            logger.trace("RequestHeaders does not contain headers for WebSocket upgrade. headers: {}", headers);
            final HttpResponse fallbackResponse = failOrFallback(ctx, req, () -> HttpResponse.of(
                    HttpStatus.BAD_REQUEST, MediaType.PLAIN_TEXT_UTF_8,
                    "The upgrade header must contain:\n" +
                    "  :protocol = websocket"));
            return WebSocketUpgradeResult.ofFailure(fallbackResponse);
        }

        HttpResponse invalidResponse = checkOrigin(ctx, headers);
        if (invalidResponse != null) {
            return WebSocketUpgradeResult.ofFailure(invalidResponse);
        }

        invalidResponse = checkVersion(headers);
        if (invalidResponse != null) {
            return WebSocketUpgradeResult.ofFailure(invalidResponse);
        }

        return WebSocketUpgradeResult.ofSuccess();
    }
Handles the HTTP/2 web socket handshake described in
<a href="https://datatracker.ietf.org/doc/html/rfc8441">Bootstrapping WebSockets with HTTP/2</a>.
These are examples of a request and the corresponding response:

<p>Request:
<pre>
HEADERS + END_HEADERS
:method = CONNECT
:protocol = websocket
:scheme = https
:path = /chat
:authority = server.example.com
sec-websocket-protocol = chat, superchat
sec-websocket-extensions = permessage-deflate
sec-websocket-version = 13
origin = http://www.example.com
</pre>

<p>Response:
<pre>
HEADERS + END_HEADERS
:status = 200
sec-websocket-protocol = chat
</pre>
core/src/main/java/com/linecorp/armeria/internal/server/websocket/DefaultWebSocketService.java