Source:
<code>public Flux<Frame> fragment(Frame frame) { final FrameType frameType = frame.getType(); final int streamId = frame.getStreamId(); final int flags = frame.flags() & ~FrameHeaderFlyweight.FLAGS_F & ~FrameHeaderFlyweight.FLAGS_M; final ByteBuf metadata = FrameHeaderFlyweight.sliceFrameMetadata(frame.content()); final ByteBuf data = FrameHeaderFlyweight.sliceFrameData(frame.content()); frame.retain(); return Flux.generate(sink -> { final int metadataLength = metadata.readableBytes(); final int dataLength = data.readableBytes(); if (metadataLength > mtu) { sink.next(Frame.PayloadFrame.from(streamId, frameType, metadata.readSlice(mtu), Unpooled.EMPTY_BUFFER, flags | FrameHeaderFlyweight.FLAGS_M | FrameHeaderFlyweight.FLAGS_F)); } else if (metadataLength > 0) { if (dataLength > 0) { <START> sink.next(Frame.PayloadFrame.from(streamId, frameType, metadata.readSlice(metadataLength), Unpooled.EMPTY_BUFFER, <END> flags | FrameHeaderFlyweight.FLAGS_M | FrameHeaderFlyweight.FLAGS_F)); } else { sink.next(Frame.PayloadFrame.from(streamId, frameType, metadata.readSlice(metadataLength), Unpooled.EMPTY_BUFFER, flags | FrameHeaderFlyweight.FLAGS_M)); frame.release(); sink.complete(); } } else if (dataLength > mtu) { sink.next(Frame.PayloadFrame.from(streamId, frameType, Unpooled.EMPTY_BUFFER, data.readSlice(mtu), flags | FrameHeaderFlyweight.FLAGS_F)); } else { sink.next(Frame.PayloadFrame.from(streamId, frameType, Unpooled.EMPTY_BUFFER, data.readSlice(dataLength), flags & ~FrameHeaderFlyweight.FLAGS_M)); frame.release(); sink.complete(); } }); }</code><technical_language>protocol spec include data in this frame <LINK_0></technical_language>

Target:
public Flux<Frame> fragment(Frame frame) { final FrameType frameType = frame.getType(); final int streamId = frame.getStreamId(); final int flags = frame.flags() & ~FrameHeaderFlyweight.FLAGS_F & ~FrameHeaderFlyweight.FLAGS_M; final ByteBuf metadata = FrameHeaderFlyweight.sliceFrameMetadata(frame.content()); final ByteBuf data = FrameHeaderFlyweight.sliceFrameData(frame.content()); frame.retain(); return Flux.generate(sink -> { final int metadataLength = metadata.readableBytes(); final int dataLength = data.readableBytes(); if (metadataLength > mtu) { sink.next(Frame.PayloadFrame.from(streamId, frameType, metadata.readSlice(mtu), Unpooled.EMPTY_BUFFER, flags | FrameHeaderFlyweight.FLAGS_M | FrameHeaderFlyweight.FLAGS_F)); } else if (metadataLength > 0) { if (dataLength > mtu - metadataLength) { sink.next(Frame.PayloadFrame.from(streamId, frameType, metadata.readSlice(metadataLength), data.readSlice(mtu - metadataLength), flags | FrameHeaderFlyweight.FLAGS_M | FrameHeaderFlyweight.FLAGS_F)); } else { sink.next(Frame.PayloadFrame.from(streamId, frameType, metadata.readSlice(metadataLength), data.readSlice(dataLength), flags | FrameHeaderFlyweight.FLAGS_M)); frame.release(); sink.complete(); } } else if (dataLength > mtu) { sink.next(Frame.PayloadFrame.from(streamId, frameType, Unpooled.EMPTY_BUFFER, data.readSlice(mtu), flags | FrameHeaderFlyweight.FLAGS_F)); } else { sink.next(Frame.PayloadFrame.from(streamId, frameType, Unpooled.EMPTY_BUFFER, data.readSlice(dataLength), flags)); frame.release(); sink.complete(); } }); }