Top Description Fields Constructors Methods
org.apache.http.impl.io

public abstract Class AbstractSessionInputBuffer

extends Object
implements SessionInputBuffer, BufferInfo
Class Inheritance
All Implemented Interfaces
org.apache.http.io.BufferInfo, org.apache.http.io.SessionInputBuffer
Known Direct Subclasses
org.apache.http.impl.io.SocketInputBuffer
Annotations
@Deprecated
Imports
java.io.IOException, .InputStream, java.nio.ByteBuffer, .CharBuffer, java.nio.charset.Charset, .CharsetDecoder, .CoderResult, .CodingErrorAction, org.apache.http.Consts, org.apache.http.io.BufferInfo, .HttpTransportMetrics, .SessionInputBuffer, org.apache.http.params.CoreConnectionPNames, .CoreProtocolPNames, .HttpParams, org.apache.http.protocol.HTTP, org.apache.http.util.Args, .ByteArrayBuffer, .CharArrayBuffer

Deprecated

(4.3) use SessionInputBufferImpl

Abstract base class for session input buffers that stream data from an arbitrary InputStream. This class buffers input data in an internal byte array for optimal input performance.

readLine(CharArrayBuffer) and readLine() methods of this class treat a lone LF as valid line delimiters in addition to CR-LF required by the HTTP specification.

Since
4.0

Field Summary

Modifier and TypeField and Description
private boolean
private byte[]
private int
private int
private CharBuffer
private Charset
private CharsetDecoder
private InputStream
private ByteArrayBuffer
private int
private HttpTransportMetricsImpl
private int
private CodingErrorAction
private CodingErrorAction

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private int
appendDecoded(final CharArrayBuffer charbuffer, final ByteBuffer bbuf)

public int
available()

Implements org.apache.http.io.BufferInfo.available.

Returns available space in the buffer.
public int
capacity()

Implements org.apache.http.io.BufferInfo.capacity.

Returns total capacity of the buffer
protected HttpTransportMetricsImpl
protected int
public HttpTransportMetrics
private int
handleDecodingResult(final CoderResult result, final CharArrayBuffer charbuffer, final ByteBuffer bbuf)

protected boolean
protected void
init(final InputStream
the source input stream.
inputStream
,
final int
the size of the internal buffer.
bufferSize
,
final HttpParams
HTTP parameters.
params
)

Deprecated as a consequence of HttpParams being deprecated.
Initializes this session input buffer.
public int
length()

Implements org.apache.http.io.BufferInfo.length.

Return length data stored in the buffer
private int

Returns:

HTTP line as a string
lineFromLineBuffer
(final CharArrayBuffer charbuffer)

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

private int
lineFromReadBuffer(final CharArrayBuffer charbuffer, final int position)

private int
public int
read()

Implements org.apache.http.io.SessionInputBuffer.read.

Reads the next byte of data from this session buffer.
public int
read(final byte[]
the buffer into which the data is read.
b
,
final int
the start offset in array b at which the data is written.
off
,
final int
the maximum number of bytes to read.
len
)

Implements org.apache.http.io.SessionInputBuffer.read.

Reads up to len bytes of data from the session buffer into an array of bytes.
public int
read(final byte[]
the buffer into which the data is read.
b
)

Implements org.apache.http.io.SessionInputBuffer.read.

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

Returns:

one line of characters
readLine
(final CharArrayBuffer
the line buffer.
charbuffer
)

Implements org.apache.http.io.SessionInputBuffer.readLine.

Reads a complete line of characters up to a line delimiter from this session buffer into the given line buffer.
public String
readLine()

Implements org.apache.http.io.SessionInputBuffer.readLine.

Reads a complete line of characters up to a line delimiter from this session buffer.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

asciiback to summary
private boolean ascii
bufferback to summary
private byte[] buffer
bufferLenback to summary
private int bufferLen
bufferPosback to summary
private int bufferPos
cbufback to summary
private CharBuffer cbuf
charsetback to summary
private Charset charset
decoderback to summary
private CharsetDecoder decoder
inStreamback to summary
private InputStream inStream
lineBufferback to summary
private ByteArrayBuffer lineBuffer
maxLineLenback to summary
private int maxLineLen
metricsback to summary
private HttpTransportMetricsImpl metrics
minChunkLimitback to summary
private int minChunkLimit
onMalformedCharActionback to summary
private CodingErrorAction onMalformedCharAction
onUnmappableCharActionback to summary
private CodingErrorAction onUnmappableCharAction

Constructor Detail

AbstractSessionInputBufferback to summary
public AbstractSessionInputBuffer()

Method Detail

appendDecodedback to summary
private int appendDecoded(final CharArrayBuffer charbuffer, final ByteBuffer bbuf) throws IOException
availableback to summary
public int available()

Implements org.apache.http.io.BufferInfo.available.

Doc from org.apache.http.io.BufferInfo.available.

Returns available space in the buffer.

Returns:int

available space.

Annotations
@Override
Since
4.1
capacityback to summary
public int capacity()

Implements org.apache.http.io.BufferInfo.capacity.

Doc from org.apache.http.io.BufferInfo.capacity.

Returns total capacity of the buffer

Returns:int

total capacity

Annotations
@Override
Since
4.1
createTransportMetricsback to summary
protected HttpTransportMetricsImpl createTransportMetrics()
Since
4.1
fillBufferback to summary
protected int fillBuffer() throws IOException
getMetricsback to summary
public HttpTransportMetrics getMetrics()

Implements org.apache.http.io.SessionInputBuffer.getMetrics.

Doc from org.apache.http.io.SessionInputBuffer.getMetrics.

Returns HttpTransportMetrics for this session buffer.

Returns:HttpTransportMetrics

transport metrics.

Annotations
@Override
handleDecodingResultback to summary
private int handleDecodingResult(final CoderResult result, final CharArrayBuffer charbuffer, final ByteBuffer bbuf) throws IOException
hasBufferedDataback to summary
protected boolean hasBufferedData()
initback to summary
protected void init(final InputStream inputStream, final int bufferSize, final HttpParams params)

Deprecated

as a consequence of HttpParams being deprecated. See corresponding docs for further information.

Initializes this session input buffer.

Parameters
inputStream:InputStream

the source input stream.

bufferSize:int

the size of the internal buffer.

params:HttpParams

HTTP parameters.

lengthback to summary
public int length()

Implements org.apache.http.io.BufferInfo.length.

Doc from org.apache.http.io.BufferInfo.length.

Return length data stored in the buffer

Returns:int

data length

Annotations
@Override
Since
4.1
lineFromLineBufferback to summary
private int lineFromLineBuffer(final CharArrayBuffer charbuffer) throws IOException

Reads 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, null 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.

Returns:int

HTTP line as a string

Exceptions
IOException:
if an I/O error occurs.
lineFromReadBufferback to summary
private int lineFromReadBuffer(final CharArrayBuffer charbuffer, final int position) throws IOException
locateLFback to summary
private int locateLF()
readback to summary
public int read() throws IOException

Implements org.apache.http.io.SessionInputBuffer.read.

Doc from org.apache.http.io.SessionInputBuffer.read.

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.

Returns:int

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

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
readback to summary
public int read(final byte[] b, final int off, final int len) throws IOException

Implements org.apache.http.io.SessionInputBuffer.read.

Doc from org.apache.http.io.SessionInputBuffer.read.

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.

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.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
readback to summary
public int read(final byte[] b) throws IOException

Implements org.apache.http.io.SessionInputBuffer.read.

Doc from org.apache.http.io.SessionInputBuffer.read.

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.

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.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
readLineback to summary
public int readLine(final CharArrayBuffer charbuffer) throws IOException

Implements org.apache.http.io.SessionInputBuffer.readLine.

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.

This method treats a lone LF as a valid line delimiters in addition to CR-LF required by the HTTP specification.

Parameters
charbuffer:CharArrayBuffer

the line buffer.

Returns:int

one line of characters

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
readLineback to summary
public String readLine() throws IOException

Implements org.apache.http.io.SessionInputBuffer.readLine.

Doc from org.apache.http.io.SessionInputBuffer.readLine.

Reads 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, null 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.

Returns:String

HTTP line as a string

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.