@Override
        protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
            if (in.readableBytes() < Http2CodecUtil.FRAME_HEADER_LENGTH) {
                return;
            }

            handledResponse = true;

            final ChannelPipeline p = ctx.pipeline();

            if (!isSettingsFrame(in)) { // The first frame must be a settings frame.
                // Http2ConnectionHandler sent the connection preface, but the server responded with
                // something else, which means the server does not support HTTP/2.
                SessionProtocolNegotiationCache.setUnsupported(remoteAddress(ctx), http2);
                if (httpPreference == HttpPreference.HTTP2_REQUIRED) {
                    finishWithNegotiationFailure(
                            ctx, http2, http1,
                            "received a non-HTTP/2 response for the HTTP/2 connection preface");
                } else {
                    // We can silently retry with HTTP/1.
                    retryWith(ctx, http1);
                }

                // We are going to close the connection really soon, so we don't need the response.
                in.skipBytes(in.readableBytes());
            } else {
                // The server responded with a non-HTTP/1 response. Continue treating the connection as HTTP/2.
                finishSuccessfully(p, http2);
            }

            p.remove(this);
        }
A handler that closes an HTTP/2 connection when the server responds with an HTTP/1 response, so that
HTTP/1 is used instead of HTTP/2 on next connection attempt.
core/src/main/java/com/linecorp/armeria/client/HttpClientPipelineConfigurator.java