private void sendContinuationFrame(InterceptorChain chain, byte[] headerBlock, int streamId,
                                       int maxFrameSize, long byteCount, boolean endStream) throws IOException {
        int offset = 0;
        while (byteCount > 0) {
            int length = (int) Math.min(maxFrameSize, byteCount);
            byteCount -= length;
            ByteArrayOutputStream os = new ByteArrayOutputStream();
            byte flags = 0;
            if (byteCount == 0) {
                flags |= Http2.FLAG_END_HEADERS;
                if (endStream) {
                    mLog.i("Http2 stream end: " + streamId);
                    flags |= Http2.FLAG_END_STREAM;
                }
            }
            os.write(frameHeader(streamId, length, FrameType.CONTINUATION.get(), flags));
            os.write(headerBlock, offset, length);
            offset += length;
            chain.process(ByteBuffer.wrap(os.toByteArray()));
        }
    }
Encodes HTTP2 request and response packets.

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