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

public Interface SessionInputBuffer

Known Direct Implementers
org.apache.hc.core5.http.impl.nio.SessionInputBufferImpl
Imports
java.io.IOException, java.nio.ByteBuffer, java.nio.channels.ReadableByteChannel, .WritableByteChannel, org.apache.hc.core5.util.CharArrayBuffer

Session input buffer for HTTP/1.1 non-blocking connections.

This interface facilitates intermediate buffering of input data streamed from a source channel and provides methods for reading lines of text.

Since
4.0

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

The number of bytes read, possibly zero, or -1 if the channel has reached end-of-stream.
fill
(ReadableByteChannel
the source channel
src
)

Makes an attempt to fill the buffer with data from the given ReadableByteChannel.

public boolean

Returns:

true if there is data in the buffer, false otherwise.
hasData
()

Determines if the buffer contains data.

public int

Returns:

buffer length.
length
()

Returns the length of this buffer.

public int

Returns:

one byte
read
()

Reads one byte from the buffer.

public int

Returns:

The number of bytes read, possibly zero.
read
(ByteBuffer
the destination buffer.
dst
,
int
the maximum number of bytes to be read.
maxLen
)

Reads a sequence of bytes from this buffer into the destination buffer, up to the given maximum limit.

public int

Returns:

The number of bytes read, possibly zero.
read
(ByteBuffer
the destination buffer.
dst
)

Reads a sequence of bytes from this buffer into the destination buffer.

public int

Returns:

The number of bytes read, possibly zero.
read
(WritableByteChannel
the destination channel.
dst
,
int
the maximum number of bytes to be read.
maxLen
)

Reads a sequence of bytes from this buffer into the destination channel, up to the given maximum limit.

public int

Returns:

The number of bytes read, possibly zero.
read
(WritableByteChannel
the destination channel.
dst
)

Reads a sequence of bytes from this buffer into the destination channel.

public boolean

Returns:

true if a sequence of chars representing a complete line has been transferred to the destination buffer, false otherwise.
readLine
(CharArrayBuffer
the destination buffer.
dst
,
boolean
end of stream flag
endOfStream
)

Attempts to transfer a complete line of characters up to a line delimiter from this buffer to the destination buffer.

Method Detail

fillback to summary
public int fill(ReadableByteChannel src) throws IOException

Makes an attempt to fill the buffer with data from the given ReadableByteChannel.

Parameters
src:ReadableByteChannel

the source channel

Returns:int

The number of bytes read, possibly zero, or -1 if the channel has reached end-of-stream.

Exceptions
IOException:
in case of an I/O error.
hasDataback to summary
public boolean hasData()

Determines if the buffer contains data.

Returns:boolean

true if there is data in the buffer, false otherwise.

lengthback to summary
public int length()

Returns the length of this buffer.

Returns:int

buffer length.

readback to summary
public int read()

Reads one byte from the buffer. If the buffer is empty this method can throw a runtime exception. The exact type of runtime exception thrown by this method depends on implementation.

Returns:int

one byte

readback to summary
public int read(ByteBuffer dst, int maxLen)

Reads a sequence of bytes from this buffer into the destination buffer, up to the given maximum limit. The exact number of bytes transferred depends on availability of data in this buffer and capacity of the destination buffer, but cannot be more than maxLen value.

Parameters
dst:ByteBuffer

the destination buffer.

maxLen:int

the maximum number of bytes to be read.

Returns:int

The number of bytes read, possibly zero.

readback to summary
public int read(ByteBuffer dst)

Reads a sequence of bytes from this buffer into the destination buffer. The exact number of bytes transferred depends on availability of data in this buffer and capacity of the destination buffer.

Parameters
dst:ByteBuffer

the destination buffer.

Returns:int

The number of bytes read, possibly zero.

readback to summary
public int read(WritableByteChannel dst, int maxLen) throws IOException

Reads a sequence of bytes from this buffer into the destination channel, up to the given maximum limit. The exact number of bytes transferred depends on availability of data in this buffer, but cannot be more than maxLen value.

Parameters
dst:WritableByteChannel

the destination channel.

maxLen:int

the maximum number of bytes to be read.

Returns:int

The number of bytes read, possibly zero.

Exceptions
IOException:
in case of an I/O error.
readback to summary
public int read(WritableByteChannel dst) throws IOException

Reads a sequence of bytes from this buffer into the destination channel. The exact number of bytes transferred depends on availability of data in this buffer.

Parameters
dst:WritableByteChannel

the destination channel.

Returns:int

The number of bytes read, possibly zero.

Exceptions
IOException:
in case of an I/O error.
readLineback to summary
public boolean readLine(CharArrayBuffer dst, boolean endOfStream) throws IOException

Attempts to transfer a complete line of characters up to a line delimiter from this buffer to the destination buffer. If a complete line is available in the buffer, the sequence of chars is transferred to the destination buffer the method returns true. The line delimiter itself is discarded. If a complete line is not available in the buffer, this method returns false without transferring anything to the destination buffer. If endOfStream parameter is set to true this method assumes the end of stream has been reached and the content currently stored in the buffer should be treated as a complete line.

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

Parameters
dst:CharArrayBuffer

the destination buffer.

endOfStream:boolean

end of stream flag

Returns:boolean

true if a sequence of chars representing a complete line has been transferred to the destination buffer, false otherwise.

Exceptions
CharacterCodingException:
in case a character encoding or decoding error occurs.
MessageConstraintException:
in case a message constraint violation.