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 class
ChunkDecoder.State
-
Field Summary
Fields Modifier and Type Field Description private long
chunkSize
private boolean
endOfChunk
private boolean
endOfStream
private Http1Config
http1Config
private CharArrayBuffer
lineBuf
private long
pos
private ChunkDecoder.State
state
private java.util.List<CharArrayBuffer>
trailerBufs
private 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 void
parseHeader()
private void
processFooters()
int
read(java.nio.ByteBuffer dst)
Reads a portion of content from the underlying channelprivate void
readChunkHead()
java.lang.String
toString()
-
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.IOException
Description copied from interface:ContentDecoder
Reads 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:ContentDecoder
Returns content trailers if available- Specified by:
getTrailers
in interfaceContentDecoder
- Overrides:
getTrailers
in classAbstractContentDecoder
- Returns:
- list of trailers
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-