private byte[] frameHeader(int streamId, int length, byte type, byte flags) {
        mLog.i("Encode a http2 frame: " + FrameType.parse(type) + " stream(" + streamId +
                ") length(" + length + ")");
        ByteBuffer header = ByteBuffer.allocate(Http2.FRAME_HEADER_LENGTH);
        header.put((byte) ((length >>> 16) & 0xff));
        header.put((byte) ((length >>> 8) & 0xff));
        header.put((byte) (length & 0xff));
        header.put((byte) (type & 0xff));
        header.put((byte) (flags & 0xff));
        header.putInt(streamId & 0x7fffffff);
        return header.array();
    }
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