Class ChunkDecoder
- java.lang.Object
-
- org.apache.hc.core5.http.impl.nio.AbstractContentDecoder
-
- org.apache.hc.core5.http.impl.nio.ChunkDecoder
-
- All Implemented Interfaces:
ContentDecoder
public class ChunkDecoder extends AbstractContentDecoder
Implements chunked transfer decoding. The content is received in small chunks. Entities transferred using this encoder can be of unlimited length.- Since:
- 4.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classChunkDecoder.State
-
Field Summary
Fields Modifier and Type Field Description private longchunkSizeprivate booleanendOfChunkprivate booleanendOfStreamprivate Http1Confighttp1Configprivate CharArrayBufferlineBufprivate longposprivate ChunkDecoder.Statestateprivate java.util.List<CharArrayBuffer>trailerBufsprivate java.util.List<Header>trailers-
Fields inherited from class org.apache.hc.core5.http.impl.nio.AbstractContentDecoder
buffer, channel, completed, metrics
-
-
Constructor Summary
Constructors Constructor Description ChunkDecoder(java.nio.channels.ReadableByteChannel channel, SessionInputBuffer buffer, Http1Config http1Config, BasicHttpTransportMetrics metrics)ChunkDecoder(java.nio.channels.ReadableByteChannel channel, SessionInputBuffer buffer, BasicHttpTransportMetrics metrics)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<? extends Header>getTrailers()Returns content trailers if availableprivate voidparseHeader()private voidprocessFooters()intread(java.nio.ByteBuffer dst)Reads a portion of content from the underlying channelprivate voidreadChunkHead()java.lang.StringtoString()-
Methods inherited from class org.apache.hc.core5.http.impl.nio.AbstractContentDecoder
buffer, channel, fillBufferFromChannel, isCompleted, metrics, readFromChannel, readFromChannel, setCompleted, setCompleted
-
-
-
-
Field Detail
-
state
private ChunkDecoder.State state
-
endOfChunk
private boolean endOfChunk
-
endOfStream
private boolean endOfStream
-
lineBuf
private CharArrayBuffer lineBuf
-
chunkSize
private long chunkSize
-
pos
private long pos
-
http1Config
private final Http1Config http1Config
-
trailerBufs
private final java.util.List<CharArrayBuffer> trailerBufs
-
trailers
private final java.util.List<Header> trailers
-
-
Constructor Detail
-
ChunkDecoder
public ChunkDecoder(java.nio.channels.ReadableByteChannel channel, SessionInputBuffer buffer, Http1Config http1Config, BasicHttpTransportMetrics metrics)- Since:
- 4.4
-
ChunkDecoder
public ChunkDecoder(java.nio.channels.ReadableByteChannel channel, SessionInputBuffer buffer, BasicHttpTransportMetrics metrics)
-
-
Method Detail
-
readChunkHead
private void readChunkHead() throws java.io.IOException- Throws:
java.io.IOException
-
parseHeader
private void parseHeader() throws java.io.IOException- Throws:
java.io.IOException
-
processFooters
private void processFooters() throws java.io.IOException- Throws:
java.io.IOException
-
read
public int read(java.nio.ByteBuffer dst) throws java.io.IOExceptionDescription copied from interface:ContentDecoderReads a portion of content from the underlying channel- Parameters:
dst- The buffer into which entity content is to be transferred- Returns:
- The number of bytes read, possibly zero, or -1 if the channel has reached end-of-stream
- Throws:
java.io.IOException- if I/O error occurs while reading content
-
getTrailers
public java.util.List<? extends Header> getTrailers()
Description copied from interface:ContentDecoderReturns content trailers if available- Specified by:
getTrailersin interfaceContentDecoder- Overrides:
getTrailersin classAbstractContentDecoder- Returns:
- list of trailers
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-