Package org.apache.http.impl.nio.codecs
Class ChunkDecoder
- java.lang.Object
-
- org.apache.http.impl.nio.codecs.AbstractContentDecoder
-
- org.apache.http.impl.nio.codecs.ChunkDecoder
-
- All Implemented Interfaces:
ContentDecoder
public class ChunkDecoder extends AbstractContentDecoder
Implements chunked transfer coding. The content is received in small chunks. Entities transferred using this encoder can be of unlimited length.- Since:
- 4.0
-
-
Field Summary
Fields Modifier and Type Field Description private long
chunkSize
private static int
COMPLETED
private MessageConstraints
constraints
private boolean
endOfChunk
private boolean
endOfStream
private Header[]
footers
private CharArrayBuffer
lineBuf
private long
pos
private static int
READ_CONTENT
private static int
READ_FOOTERS
private int
state
private java.util.List<CharArrayBuffer>
trailerBufs
-
Fields inherited from class org.apache.http.impl.nio.codecs.AbstractContentDecoder
buffer, channel, completed, metrics
-
-
Constructor Summary
Constructors Constructor Description ChunkDecoder(java.nio.channels.ReadableByteChannel channel, SessionInputBuffer buffer, MessageConstraints constraints, HttpTransportMetricsImpl metrics)
ChunkDecoder(java.nio.channels.ReadableByteChannel channel, SessionInputBuffer buffer, HttpTransportMetricsImpl metrics)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Header[]
getFooters()
private 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.http.impl.nio.codecs.AbstractContentDecoder
fillBufferFromChannel, isCompleted, readFromChannel, readFromChannel, setCompleted, setCompleted
-
-
-
-
Field Detail
-
READ_CONTENT
private static final int READ_CONTENT
- See Also:
- Constant Field Values
-
READ_FOOTERS
private static final int READ_FOOTERS
- See Also:
- Constant Field Values
-
COMPLETED
private static final int COMPLETED
- See Also:
- Constant Field Values
-
state
private int state
-
endOfChunk
private boolean endOfChunk
-
endOfStream
private boolean endOfStream
-
lineBuf
private CharArrayBuffer lineBuf
-
chunkSize
private long chunkSize
-
pos
private long pos
-
constraints
private final MessageConstraints constraints
-
trailerBufs
private final java.util.List<CharArrayBuffer> trailerBufs
-
footers
private Header[] footers
-
-
Constructor Detail
-
ChunkDecoder
public ChunkDecoder(java.nio.channels.ReadableByteChannel channel, SessionInputBuffer buffer, MessageConstraints constraints, HttpTransportMetricsImpl metrics)
- Since:
- 4.4
-
ChunkDecoder
public ChunkDecoder(java.nio.channels.ReadableByteChannel channel, SessionInputBuffer buffer, HttpTransportMetricsImpl 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
-
getFooters
public Header[] getFooters()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-