private void readSettingsFrame(ChannelHandlerContext ctx, ByteBuf payload,
            Http2FrameListener listener) throws Http2Exception {
        if (flags.ack()) {
            listener.onSettingsAckRead(ctx);
        } else {
            int numSettings = payloadLength / SETTING_ENTRY_LENGTH;
            Http2Settings settings = new Http2Settings();
            for (int index = 0; index < numSettings; ++index) {
                char id = (char) payload.readUnsignedShort();
                long value = payload.readUnsignedInt();
                try {
                    settings.put(id, Long.valueOf(value));
                } catch (IllegalArgumentException e) {
                    if (id == SETTINGS_INITIAL_WINDOW_SIZE) {
                        throw connectionError(FLOW_CONTROL_ERROR, e,
                                "Failed setting initial window size: %s", e.getMessage());
                    }
                    throw connectionError(PROTOCOL_ERROR, e, "Protocol error: %s", e.getMessage());
                }
            }
            listener.onSettingsRead(ctx, settings);
        }
    }
@Test
    public void readSettingsFrame() throws Http2Exception {
        ByteBuf input = Unpooled.buffer();
        try {
            writeFrameHeader(input, 6, SETTINGS, new Http2Flags(), 0);
            input.writeShort(SETTINGS_MAX_HEADER_LIST_SIZE);
            input.writeInt(1024);
            frameReader.readFrame(ctx, input, listener);

            listener.onSettingsRead(ctx, new Http2Settings().maxHeaderListSize(1024));
        } finally {
            input.release();
        }
    }