Package org.apache.http.io
Interface SessionInputBuffer
- 
- All Known Implementing Classes:
 AbstractSessionInputBuffer,LoggingSessionInputBuffer,SessionInputBufferImpl,SocketInputBuffer
public interface SessionInputBufferSession input buffer for blocking connections. This interface is similar to InputStream class, but it also provides methods for reading lines of text.Implementing classes are also expected to manage intermediate data buffering for optimal input performance.
- Since:
 - 4.0
 
 
- 
- 
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description HttpTransportMetricsgetMetrics()ReturnsHttpTransportMetricsfor this session buffer.booleanisDataAvailable(int timeout)Deprecated.(4.3) do not use.intread()Reads the next byte of data from this session buffer.intread(byte[] b)Reads some number of bytes from the session buffer and stores them into the buffer arrayb.intread(byte[] b, int off, int len)Reads up tolenbytes of data from the session buffer into an array of bytes.java.lang.StringreadLine()Reads a complete line of characters up to a line delimiter from this session buffer.intreadLine(CharArrayBuffer buffer)Reads a complete line of characters up to a line delimiter from this session buffer into the given line buffer. 
 - 
 
- 
- 
Method Detail
- 
read
int read(byte[] b, int off, int len) throws java.io.IOExceptionReads up tolenbytes of data from the session buffer into an array of bytes. An attempt is made to read as many aslenbytes, 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
offis negative, orlenis negative, oroff+lenis greater than the length of the arrayb, then anIndexOutOfBoundsExceptionis thrown.- Parameters:
 b- the buffer into which the data is read.off- the start offset in arraybat which the data is written.len- the maximum number of bytes to read.- Returns:
 - the total number of bytes read into the buffer, or
             
-1if there is no more data because the end of the stream has been reached. - Throws:
 java.io.IOException- if an I/O error occurs.
 
- 
read
int read(byte[] b) throws java.io.IOException
Reads some number of bytes from the session buffer and stores them into the buffer arrayb. 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- the buffer into which the data is read.- Returns:
 - the total number of bytes read into the buffer, or
             
-1is there is no more data because the end of the stream has been reached. - Throws:
 java.io.IOException- if an I/O error occurs.
 
- 
read
int read() throws java.io.IOException
Reads the next byte of data from this session buffer. The value byte is returned as anintin the range0to255. If no byte is available because the end of the stream has been reached, the value-1is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.- Returns:
 - the next byte of data, or 
-1if the end of the stream is reached. - Throws:
 java.io.IOException- if an I/O error occurs.
 
- 
readLine
int readLine(CharArrayBuffer buffer) throws java.io.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-1is 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- the line buffer.- Returns:
 - one line of characters
 - Throws:
 java.io.IOException- if an I/O error occurs.
 
- 
readLine
java.lang.String readLine() throws java.io.IOExceptionReads a complete line of characters up to a line delimiter from this session buffer. The line delimiter itself is discarded. If no char is available because the end of the stream has been reached,nullis 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.
- Returns:
 - HTTP line as a string
 - Throws:
 java.io.IOException- if an I/O error occurs.
 
- 
isDataAvailable
@Deprecated boolean isDataAvailable(int timeout) throws java.io.IOExceptionDeprecated.(4.3) do not use. This function should be provided at the connection levelBlocks until some data becomes available in the session buffer or the given timeout period in milliseconds elapses. If the timeout value is0this method blocks indefinitely.- Parameters:
 timeout- in milliseconds.- Returns:
 trueif some data is available in the session buffer orfalseotherwise.- Throws:
 java.io.IOException- if an I/O error occurs.
 
- 
getMetrics
HttpTransportMetrics getMetrics()
ReturnsHttpTransportMetricsfor this session buffer.- Returns:
 - transport metrics.
 
 
 - 
 
 -