Package org.eclipse.jetty.io
Class ChunkAccumulator
java.lang.Object
org.eclipse.jetty.io.ChunkAccumulator
An accumulator of
Content.Chunk
s used to facilitate minimal copy
aggregation of multiple chunks.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
add
(Content.Chunk chunk) Add aContent.Chunk
to the accumulator.void
close()
int
length()
Get the total length of the accumulatedContent.Chunk
s.CompletableFuture<byte[]>
readAll
(Content.Source source) Deprecated, for removal: This API element is subject to removal in a future version.CompletableFuture<byte[]>
readAll
(Content.Source source, int maxSize) Deprecated, for removal: This API element is subject to removal in a future version.readAll
(Content.Source source, ByteBufferPool pool, boolean direct, int maxSize) Deprecated, for removal: This API element is subject to removal in a future version.byte[]
take()
take
(ByteBufferPool pool, boolean direct)
-
Constructor Details
-
ChunkAccumulator
public ChunkAccumulator()
-
-
Method Details
-
add
Add aContent.Chunk
to the accumulator.- Parameters:
chunk
- TheContent.Chunk
to accumulate. If a reference is kept to the chunk (rather than a copy), it will be retained.- Returns:
- true if the
Content.Chunk
had content and was added to the accumulator. - Throws:
ArithmeticException
- if more thatInteger.MAX_VALUE
bytes are added.IllegalArgumentException
- if the passedContent.Chunk
is afailure
.
-
length
public int length()Get the total length of the accumulatedContent.Chunk
s.- Returns:
- The total length in bytes.
-
take
public byte[] take() -
take
-
close
public void close() -
readAll
@Deprecated(forRemoval=true, since="12.0.15") public CompletableFuture<byte[]> readAll(Content.Source source) Deprecated, for removal: This API element is subject to removal in a future version. -
readAll
@Deprecated(forRemoval=true, since="12.0.15") public CompletableFuture<byte[]> readAll(Content.Source source, int maxSize) Deprecated, for removal: This API element is subject to removal in a future version. -
readAll
@Deprecated(forRemoval=true, since="12.0.15") public CompletableFuture<RetainableByteBuffer> readAll(Content.Source source, ByteBufferPool pool, boolean direct, int maxSize) Deprecated, for removal: This API element is subject to removal in a future version.- Parameters:
source
- TheContent.Source
to readpool
- TheByteBufferPool
to acquire the buffer from, or null for a nonRetainable
bufferdirect
- True if the buffer should be direct.maxSize
- The maximum size to read, or -1 for no limit- Returns:
- A
CompletableFuture
that will be completed when the complete content is read or failed if the max size is exceeded or there is a read error.
-