public class SessionInputBufferImpl extends Object implements SessionInputBuffer
InputStream
. This class buffers input data in
an internal byte array for optimal input performance.
readLine(CharArrayBuffer, InputStream)
method of this class treat a lone
LF as valid line delimiters in addition to CR-LF required
by the HTTP specification.
Constructor and Description |
---|
SessionInputBufferImpl(BasicHttpTransportMetrics metrics,
int bufferSize) |
SessionInputBufferImpl(BasicHttpTransportMetrics metrics,
int bufferSize,
int minChunkLimit,
int maxLineLen,
CharsetDecoder charDecoder)
Creates new instance of SessionInputBufferImpl.
|
SessionInputBufferImpl(int bufferSize) |
SessionInputBufferImpl(int bufferSize,
CharsetDecoder decoder) |
SessionInputBufferImpl(int bufferSize,
int maxLineLen) |
Modifier and Type | Method and Description |
---|---|
int |
available()
Returns available space in the buffer.
|
int |
capacity()
Returns total capacity of the buffer
|
void |
clear() |
int |
fillBuffer(InputStream inputStream) |
HttpTransportMetrics |
getMetrics()
Returns
HttpTransportMetrics for this session buffer. |
boolean |
hasBufferedData() |
int |
length()
Returns length data stored in the buffer
|
int |
read(byte[] b,
InputStream inputStream)
Reads some number of bytes from the session buffer and stores them into
the buffer array
b . |
int |
read(byte[] b,
int off,
int len,
InputStream inputStream)
Reads up to
len bytes of data from the session buffer into
an array of bytes. |
int |
read(InputStream inputStream)
Reads the next byte of data from this session buffer.
|
int |
readLine(CharArrayBuffer charBuffer,
InputStream inputStream)
Reads a complete line of characters up to a line delimiter from this
session buffer into the given line buffer.
|
public SessionInputBufferImpl(BasicHttpTransportMetrics metrics, int bufferSize, int minChunkLimit, int maxLineLen, CharsetDecoder charDecoder)
metrics
- HTTP transport metrics.bufferSize
- buffer size. Must be a positive number.minChunkLimit
- size limit below which data chunks should be buffered in memory
in order to minimize native method invocations on the underlying network socket.
The optimal value of this parameter can be platform specific and defines a trade-off
between performance of memory copy operations and that of native method invocation.
If negative default chunk limited will be used.maxLineLen
- maximum line length.charDecoder
- charDecoder to be used for decoding HTTP protocol elements.
If null
simple type cast will be used for byte to char conversion.public SessionInputBufferImpl(BasicHttpTransportMetrics metrics, int bufferSize)
public SessionInputBufferImpl(int bufferSize, int maxLineLen)
public SessionInputBufferImpl(int bufferSize, CharsetDecoder decoder)
public SessionInputBufferImpl(int bufferSize)
public int capacity()
SessionInputBuffer
capacity
in interface SessionInputBuffer
public int length()
SessionInputBuffer
length
in interface SessionInputBuffer
public int available()
SessionInputBuffer
available
in interface SessionInputBuffer
public int fillBuffer(InputStream inputStream) throws IOException
IOException
public boolean hasBufferedData()
public void clear()
public int read(InputStream inputStream) throws IOException
SessionInputBuffer
int
in the range 0
to
255
. If no byte is available because the end of the stream
has been reached, the value -1
is returned. This method
blocks until input data is available, the end of the stream is detected,
or an exception is thrown.read
in interface SessionInputBuffer
inputStream
- Input stream-1
if the end of the
stream is reached.IOException
- if an I/O error occurs.public int read(byte[] b, int off, int len, InputStream inputStream) throws IOException
SessionInputBuffer
len
bytes of data from the session buffer into
an array of bytes. An attempt is made to read as many as
len
bytes, but a smaller number may be read, possibly
zero. The number of bytes actually read is returned as an integer.
This method blocks until input data is available, end of file is detected, or an exception is thrown.
If off
is negative, or len
is negative, or
off+len
is greater than the length of the array
b
, then an IndexOutOfBoundsException
is
thrown.
read
in interface SessionInputBuffer
b
- the buffer into which the data is read.off
- the start offset in array b
at which the data is written.len
- the maximum number of bytes to read.inputStream
- Input stream-1
if there is no more data because the end of
the stream has been reached.IOException
- if an I/O error occurs.public int read(byte[] b, InputStream inputStream) throws IOException
SessionInputBuffer
b
. The number of bytes actually read is
returned as an integer. This method blocks until input data is
available, end of file is detected, or an exception is thrown.read
in interface SessionInputBuffer
b
- the buffer into which the data is read.inputStream
- Input stream-1
is there is no more data because the end of
the stream has been reached.IOException
- if an I/O error occurs.public int readLine(CharArrayBuffer charBuffer, InputStream inputStream) throws IOException
-1
is returned. This method blocks until input
data is available, end of file is detected, or an exception is thrown.
This method treats a lone LF as a valid line delimiters in addition to CR-LF required by the HTTP specification.
readLine
in interface SessionInputBuffer
charBuffer
- the line buffer, one line of characters upon returninputStream
- Input stream-1
is there is no more data because the end of
the stream has been reached.IOException
- if an I/O error occurs.public HttpTransportMetrics getMetrics()
SessionInputBuffer
HttpTransportMetrics
for this session buffer.getMetrics
in interface SessionInputBuffer
Copyright © 2005–2021 The Apache Software Foundation. All rights reserved.