private void decodeData(ByteBuffer buffer, int length, byte flags, int streamId,
                            DecodeCallback callback) throws IOException {
        if (streamId == 0) {
            throw new IOException("Http2 PROTOCOL_ERROR: TYPE_DATA streamId == 0");
        }
        boolean gzipped = (flags & Http2.FLAG_COMPRESSED) != 0;
        if (gzipped) {
            throw new IOException("Http2 PROTOCOL_ERROR: FLAG_COMPRESSED without SETTINGS_COMPRESS_DATA");
        }
        short padding = (flags & Http2.FLAG_PADDED) != 0 ? (short) (buffer.get() & 0xff) : 0;
        length = lengthWithoutPadding(length, flags, padding);
        boolean endStream = (flags & Http2.FLAG_END_STREAM) != 0;
        if (length > 0) {
            callback.onResult(ByteBuffer.wrap(Arrays.copyOfRange(buffer.array(), buffer.position(),
                    buffer.position() + length)), endStream);
        } else {
            // Notify stream is end
            callback.onResult(ByteBuffer.allocate(0), endStream);
            if (endStream) {
                callback.onSkip(endStream(FrameType.DATA, 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