Note that this class NEVER closes the underlying stream, even when
close() gets called. Instead, it will read until the "end" of its
chunking on close, which allows for the seamless execution of subsequent
HTTP 1.1 requests, while not requiring the client to remember to read the
entire contents of the response.
| Modifier and Type | Class and Description |
|---|---|
| private static enum |
| Modifier and Type | Field and Description |
|---|---|
| private final SessionInputBuffer | buffer
The session input buffer |
| private static final int | |
| private long | chunkSize
The chunk size |
| private boolean | closed
True if this stream is closed |
| private static final Header[] | |
| private boolean | eof
True if we've reached the end of stream |
| private Header[] | |
| private final Http1Config | |
| private final InputStream | |
| private final CharArrayBuffer | |
| private long | pos
The current position within the current chunk |
| private ChunkedInputStream. |
| Access | Constructor and Description |
|---|---|
| public | ChunkedInputStream(final SessionInputBuffer
Session input buffer buffer, final InputStream Input stream inputStream, final Http1Config Message http1Config. If http1Config)null Http1Config#DEFAULT will be used.Default constructor. |
| public | ChunkedInputStream(final SessionInputBuffer
Session input buffer buffer, final InputStream Input stream inputStream)Wraps session input stream and reads chunk coded input. |
| Modifier and Type | Method and Description |
|---|---|
| public int | available()
Overrides java. |
| public void | close()
Overrides java. Implements java. |
| private long | getChunkSize()
Expects the stream to start with a chunksize in hex with optional comments after a semicolon. |
| public Header[] | |
| private void | |
| private void | |
| public int | Returns: -1 of the end of the stream has been reached or the next data byteImplements abstract java. Returns all the data in a chunked stream in coalesced form. |
| public int | Returns: The number of bytes returned or -1 if the end of stream has been reached.The byte array that will hold the contents from the stream. b, final int The offset into the byte array at which bytes will start to be
placed. off, final int the maximum number of bytes that can be returned. len)Overrides java. |
| public int | Returns: The number of bytes returned or -1 if the end of stream has been reached.The byte array that will hold the contents from the stream. b)Overrides java. |
| buffer | back to summary |
|---|---|
| private final SessionInputBuffer buffer The session input buffer | |
| BUFFER_SIZE | back to summary |
|---|---|
| private static final int BUFFER_SIZE | |
| chunkSize | back to summary |
|---|---|
| private long chunkSize The chunk size | |
| closed | back to summary |
|---|---|
| private boolean closed True if this stream is closed | |
| EMPTY_FOOTERS | back to summary |
|---|---|
| private static final Header[] EMPTY_FOOTERS | |
| eof | back to summary |
|---|---|
| private boolean eof True if we've reached the end of stream | |
| footers | back to summary |
|---|---|
| private Header[] footers | |
| http1Config | back to summary |
|---|---|
| private final Http1Config http1Config | |
| inputStream | back to summary |
|---|---|
| private final InputStream inputStream | |
| lineBuffer | back to summary |
|---|---|
| private final CharArrayBuffer lineBuffer | |
| pos | back to summary |
|---|---|
| private long pos The current position within the current chunk | |
| state | back to summary |
|---|---|
| private ChunkedInputStream. | |
| ChunkedInputStream | back to summary |
|---|---|
| public ChunkedInputStream(final SessionInputBuffer buffer, final InputStream inputStream, final Http1Config http1Config) Default constructor.
| |
| ChunkedInputStream | back to summary |
|---|---|
| public ChunkedInputStream(final SessionInputBuffer buffer, final InputStream inputStream) Wraps session input stream and reads chunk coded input.
| |
| available | back to summary |
|---|---|
| public int available() throws IOException Overrides java. Doc from java. Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected. The read might be on the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes. Note that while some implementations of A subclass's implementation of this method may choose to throw an
| |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides java. Implements java. Reads the remainder of the chunked message, leaving the underlying stream at a position to start reading the next response without scanning. But does NOT close the underlying stream.
| |
| getChunkSize | back to summary |
|---|---|
| private long getChunkSize() throws IOException Expects the stream to start with a chunksize in hex with optional comments after a semicolon. The line must end with a CRLF: "a3; some comment\r\n" Positions the stream at the start of the next line. | |
| getFooters | back to summary |
|---|---|
| public Header[] getFooters() | |
| nextChunk | back to summary |
|---|---|
| private void nextChunk() throws IOException Read the next chunk.
| |
| parseTrailerHeaders | back to summary |
|---|---|
| private void parseTrailerHeaders() throws IOException Reads and stores the Trailer headers.
| |
| read | back to summary |
|---|---|
| public int read() throws IOException Implements abstract java. Returns all the data in a chunked stream in coalesced form. A chunk is followed by a CRLF. The method returns -1 as soon as a chunksize of 0 is detected. Trailer headers are read automatically at the end of the stream and can be obtained with the getResponseFooters() method.
| |
| read | back to summary |
|---|---|
| public int read(final byte[] b, final int off, final int len) throws IOException Overrides java. Read some bytes from the stream.
| |
| read | back to summary |
|---|---|
| public int read(final byte[] b) throws IOException Overrides java. Read some bytes from the stream.
| |
| Modifier and Type | Field and Description |
|---|---|
| public static final ChunkedInputStream. | |
| public static final ChunkedInputStream. | |
| public static final ChunkedInputStream. | |
| public static final ChunkedInputStream. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static ChunkedInputStream. | |
| public static ChunkedInputStream. |
| CHUNK_CRLF | back to summary |
|---|---|
| public static final ChunkedInputStream. | |
| CHUNK_DATA | back to summary |
|---|---|
| public static final ChunkedInputStream. | |
| CHUNK_INVALID | back to summary |
|---|---|
| public static final ChunkedInputStream. | |
| CHUNK_LEN | back to summary |
|---|---|
| public static final ChunkedInputStream. | |
| State | back to summary |
|---|---|
| private State() | |
| valueOf | back to summary |
|---|---|
| public static ChunkedInputStream. | |
| values | back to summary |
|---|---|
| public static ChunkedInputStream. | |