Top Description Methods
org.apache.hc.core5.http.io

public Interface SessionInputBuffer

Known Direct Implementers
org.apache.hc.core5.http.impl.io.SessionInputBufferImpl
Imports
java.io.IOException, .InputStream, org.apache.hc.core5.util.CharArrayBuffer

Session input buffer for HTTP/1.1 blocking connections.

This interface facilitates intermediate buffering of input data streamed from an input stream and provides methods for reading lines of text.

Since
4.0

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

available space.
available
()

Returns available space in the buffer.

public int

Returns:

total capacity
capacity
()

Returns total capacity of the buffer

public HttpTransportMetrics

Returns:

transport metrics.
getMetrics
()

Returns HttpTransportMetrics for this session buffer.

public int

Returns:

data length
length
()

Returns length data stored in the buffer

public int

Returns:

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
read
(byte[]
the buffer into which the data is read.
b
,
int
the start offset in array b at which the data is written.
off
,
int
the maximum number of bytes to read.
len
,
InputStream
Input stream
inputStream
)

Reads up to len bytes of data from the session buffer into an array of bytes.

public int

Returns:

the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached.
read
(byte[]
the buffer into which the data is read.
b
,
InputStream
Input stream
inputStream
)

Reads some number of bytes from the session buffer and stores them into the buffer array b.

public int

Returns:

the next byte of data, or -1 if the end of the stream is reached.
read
(InputStream
Input stream
inputStream
)

Reads the next byte of data from this session buffer.

public int

Returns:

the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached.
readLine
(CharArrayBuffer
the line buffer, one line of characters upon return
buffer
,
InputStream
Input stream
inputStream
)

Reads a complete line of characters up to a line delimiter from this session buffer into the given line buffer.

Method Detail

availableback to summary
public int available()

Returns available space in the buffer.

Returns:int

available space.

capacityback to summary
public int capacity()

Returns total capacity of the buffer

Returns:int

total capacity

getMetricsback to summary
public HttpTransportMetrics getMetrics()

Returns HttpTransportMetrics for this session buffer.

Returns:HttpTransportMetrics

transport metrics.

lengthback to summary
public int length()

Returns length data stored in the buffer

Returns:int

data length

readback to summary
public int read(byte[] b, int off, int len, InputStream inputStream) throws IOException

Reads up to 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.

Parameters
b:byte[]

the buffer into which the data is read.

off:int

the start offset in array b at which the data is written.

len:int

the maximum number of bytes to read.

inputStream:InputStream

Input stream

Returns:int

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.

Exceptions
IOException:
if an I/O error occurs.
readback to summary
public int read(byte[] b, InputStream inputStream) throws IOException

Reads some number of bytes from the session buffer and stores them into the buffer array 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.

Parameters
b:byte[]

the buffer into which the data is read.

inputStream:InputStream

Input stream

Returns:int

the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached.

Exceptions
IOException:
if an I/O error occurs.
readback to summary
public int read(InputStream inputStream) throws IOException

Reads the next byte of data from this session buffer. The value byte is returned as an 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.

Parameters
inputStream:InputStream

Input stream

Returns:int

the next byte of data, or -1 if the end of the stream is reached.

Exceptions
IOException:
if an I/O error occurs.
readLineback to summary
public int readLine(CharArrayBuffer buffer, InputStream inputStream) throws IOException

Reads a complete line of characters up to a line delimiter from this session buffer into the given line buffer. The number of chars actually read is returned as an integer. The line delimiter itself is discarded. If no char is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, end of file is detected, or an exception is thrown.

The choice of a char encoding and line delimiter sequence is up to the specific implementations of this interface.

Parameters
buffer:CharArrayBuffer

the line buffer, one line of characters upon return

inputStream:InputStream

Input stream

Returns:int

the total number of bytes read into the buffer, or -1 is there is no more data because the end of the stream has been reached.

Exceptions
IOException:
if an I/O error occurs.