Class ChunkBuffer


  • public final class ChunkBuffer
    extends Object
    Class that will buffer incoming BufferBytes to chunks of bufferSize. If totalBytes is not provided, i.e. content-length is unknown, getBufferedData() should be used in the Subscriber's onComplete() to check for a final chunk that is smaller than the chunk size, and send if present.
    • Method Detail

      • split

        public Iterable<ByteBuffer> split​(ByteBuffer inputByteBuffer)
        Split the input ByteBuffer into multiple smaller ByteBuffers, each of which contains chunkSize worth of bytes. If the last chunk of the input ByteBuffer contains less than chunkSize data, the last chunk will be buffered.
      • getBufferedData

        public Optional<ByteBuffer> getBufferedData()
        Retrieve the current buffered data.