private void decodeHeaders(ByteBuffer buffer, Hpack.Reader reader, int length, byte flags,
                               int streamId, DecodeCallback callback) throws IOException {
        // +---------------+
        // |Pad Length? (8)|
        // +-+-------------+-----------------------------------------------+
        // |E|                 Stream Dependency? (31)                     |
        // +-+-------------+-----------------------------------------------+
        // |  Weight? (8)  |
        // +-+-------------+-----------------------------------------------+
        // |                   Header Block Fragment (*)                 ...
        // +---------------------------------------------------------------+
        // |                           Padding (*)                       ...
        // +---------------------------------------------------------------+
        if (streamId == 0) {
            throw new IOException("Http2 PROTOCOL_ERROR: TYPE_HEADERS streamId == 0");
        }
        short padding = (flags & Http2.FLAG_PADDED) != 0 ? (short) (buffer.get() & 0xff) : 0;
        if ((flags & Http2.FLAG_PRIORITY) != 0) {
            // Skip priority.
            buffer.position(buffer.position() + 5);
        }
        length = lengthWithoutPadding(length, flags, padding);
        boolean endStream = (flags & Http2.FLAG_END_STREAM) != 0;
        if (length > 0) {
            decodeHeaderBlock(buffer, reader, flags, callback);
        } else {
            // Notify stream is end
            callback.onResult(ByteBuffer.allocate(0), endStream);
            if (endStream) {
                callback.onSkip(endStream(FrameType.HEADERS, streamId));
            }
        }
    }
Decodes HTTP2 request and response packets.

@author Megatron King
@since 2019/1/5 14:19
netbare-core/src/main/java/com/github/megatronking/netbare/http2/Http2DecodeInterceptor.java