Class AbstractSessionInputBuffer
- java.lang.Object
-
- org.apache.http.impl.io.AbstractSessionInputBuffer
-
- All Implemented Interfaces:
BufferInfo
,SessionInputBuffer
- Direct Known Subclasses:
SocketInputBuffer
@Deprecated public abstract class AbstractSessionInputBuffer extends java.lang.Object implements SessionInputBuffer, BufferInfo
Deprecated.(4.3) useSessionInputBufferImpl
Abstract base class for session input buffers that stream data from an arbitraryInputStream
. This class buffers input data in an internal byte array for optimal input performance.readLine(CharArrayBuffer)
andreadLine()
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
Fields Modifier and Type Field Description private boolean
ascii
Deprecated.private byte[]
buffer
Deprecated.private int
bufferLen
Deprecated.private int
bufferPos
Deprecated.private java.nio.CharBuffer
cbuf
Deprecated.private java.nio.charset.Charset
charset
Deprecated.private java.nio.charset.CharsetDecoder
decoder
Deprecated.private java.io.InputStream
inStream
Deprecated.private ByteArrayBuffer
lineBuffer
Deprecated.private int
maxLineLen
Deprecated.private HttpTransportMetricsImpl
metrics
Deprecated.private int
minChunkLimit
Deprecated.private java.nio.charset.CodingErrorAction
onMalformedCharAction
Deprecated.private java.nio.charset.CodingErrorAction
onUnmappableCharAction
Deprecated.
-
Constructor Summary
Constructors Constructor Description AbstractSessionInputBuffer()
Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private int
appendDecoded(CharArrayBuffer charbuffer, java.nio.ByteBuffer bbuf)
Deprecated.int
available()
Deprecated.Returns available space in the buffer.int
capacity()
Deprecated.Returns total capacity of the bufferprotected HttpTransportMetricsImpl
createTransportMetrics()
Deprecated.protected int
fillBuffer()
Deprecated.HttpTransportMetrics
getMetrics()
Deprecated.ReturnsHttpTransportMetrics
for this session buffer.private int
handleDecodingResult(java.nio.charset.CoderResult result, CharArrayBuffer charbuffer, java.nio.ByteBuffer bbuf)
Deprecated.protected boolean
hasBufferedData()
Deprecated.protected void
init(java.io.InputStream inputStream, int bufferSize, HttpParams params)
Deprecated.Initializes this session input buffer.int
length()
Deprecated.Return length data stored in the bufferprivate int
lineFromLineBuffer(CharArrayBuffer charbuffer)
Deprecated.Reads a complete line of characters up to a line delimiter from this session buffer.private int
lineFromReadBuffer(CharArrayBuffer charbuffer, int position)
Deprecated.private int
locateLF()
Deprecated.int
read()
Deprecated.Reads the next byte of data from this session buffer.int
read(byte[] b)
Deprecated.Reads some number of bytes from the session buffer and stores them into the buffer arrayb
.int
read(byte[] b, int off, int len)
Deprecated.Reads up tolen
bytes of data from the session buffer into an array of bytes.java.lang.String
readLine()
Deprecated.Reads a complete line of characters up to a line delimiter from this session buffer.int
readLine(CharArrayBuffer charbuffer)
Deprecated.Reads a complete line of characters up to a line delimiter from this session buffer into the given line buffer.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.http.io.SessionInputBuffer
isDataAvailable
-
-
-
-
Field Detail
-
inStream
private java.io.InputStream inStream
Deprecated.
-
buffer
private byte[] buffer
Deprecated.
-
lineBuffer
private ByteArrayBuffer lineBuffer
Deprecated.
-
charset
private java.nio.charset.Charset charset
Deprecated.
-
ascii
private boolean ascii
Deprecated.
-
maxLineLen
private int maxLineLen
Deprecated.
-
minChunkLimit
private int minChunkLimit
Deprecated.
-
metrics
private HttpTransportMetricsImpl metrics
Deprecated.
-
onMalformedCharAction
private java.nio.charset.CodingErrorAction onMalformedCharAction
Deprecated.
-
onUnmappableCharAction
private java.nio.charset.CodingErrorAction onUnmappableCharAction
Deprecated.
-
bufferPos
private int bufferPos
Deprecated.
-
bufferLen
private int bufferLen
Deprecated.
-
decoder
private java.nio.charset.CharsetDecoder decoder
Deprecated.
-
cbuf
private java.nio.CharBuffer cbuf
Deprecated.
-
-
Method Detail
-
init
protected void init(java.io.InputStream inputStream, int bufferSize, HttpParams params)
Deprecated.Initializes this session input buffer.- Parameters:
inputStream
- the source input stream.bufferSize
- the size of the internal buffer.params
- HTTP parameters.
-
createTransportMetrics
protected HttpTransportMetricsImpl createTransportMetrics()
Deprecated.- Since:
- 4.1
-
capacity
public int capacity()
Deprecated.Description copied from interface:BufferInfo
Returns total capacity of the buffer- Specified by:
capacity
in interfaceBufferInfo
- Returns:
- total capacity
- Since:
- 4.1
-
length
public int length()
Deprecated.Description copied from interface:BufferInfo
Return length data stored in the buffer- Specified by:
length
in interfaceBufferInfo
- Returns:
- data length
- Since:
- 4.1
-
available
public int available()
Deprecated.Description copied from interface:BufferInfo
Returns available space in the buffer.- Specified by:
available
in interfaceBufferInfo
- Returns:
- available space.
- Since:
- 4.1
-
fillBuffer
protected int fillBuffer() throws java.io.IOException
Deprecated.- Throws:
java.io.IOException
-
hasBufferedData
protected boolean hasBufferedData()
Deprecated.
-
read
public int read() throws java.io.IOException
Deprecated.Description copied from interface:SessionInputBuffer
Reads the next byte of data from this session buffer. The value byte is returned as anint
in the range0
to255
. 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.- Specified by:
read
in interfaceSessionInputBuffer
- Returns:
- the next byte of data, or
-1
if the end of the stream is reached. - Throws:
java.io.IOException
- if an I/O error occurs.
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException
Deprecated.Description copied from interface:SessionInputBuffer
Reads up tolen
bytes of data from the session buffer into an array of bytes. An attempt is made to read as many aslen
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, orlen
is negative, oroff+len
is greater than the length of the arrayb
, then anIndexOutOfBoundsException
is thrown.- Specified by:
read
in interfaceSessionInputBuffer
- Parameters:
b
- the buffer into which the data is read.off
- the start offset in arrayb
at which the data is written.len
- the maximum number of bytes to read.- 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. - Throws:
java.io.IOException
- if an I/O error occurs.
-
read
public int read(byte[] b) throws java.io.IOException
Deprecated.Description copied from interface:SessionInputBuffer
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.- Specified by:
read
in interfaceSessionInputBuffer
- Parameters:
b
- the buffer into which the data is read.- 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. - Throws:
java.io.IOException
- if an I/O error occurs.
-
locateLF
private int locateLF()
Deprecated.
-
readLine
public int readLine(CharArrayBuffer charbuffer) throws java.io.IOException
Deprecated.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.
- Specified by:
readLine
in interfaceSessionInputBuffer
- Parameters:
charbuffer
- the line buffer.- Returns:
- one line of characters
- Throws:
java.io.IOException
- if an I/O error occurs.
-
lineFromLineBuffer
private int lineFromLineBuffer(CharArrayBuffer charbuffer) throws java.io.IOException
Deprecated.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:
- HTTP line as a string
- Throws:
java.io.IOException
- if an I/O error occurs.
-
lineFromReadBuffer
private int lineFromReadBuffer(CharArrayBuffer charbuffer, int position) throws java.io.IOException
Deprecated.- Throws:
java.io.IOException
-
appendDecoded
private int appendDecoded(CharArrayBuffer charbuffer, java.nio.ByteBuffer bbuf) throws java.io.IOException
Deprecated.- Throws:
java.io.IOException
-
handleDecodingResult
private int handleDecodingResult(java.nio.charset.CoderResult result, CharArrayBuffer charbuffer, java.nio.ByteBuffer bbuf) throws java.io.IOException
Deprecated.- Throws:
java.io.IOException
-
readLine
public java.lang.String readLine() throws java.io.IOException
Deprecated.Description copied from interface:SessionInputBuffer
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.
- Specified by:
readLine
in interfaceSessionInputBuffer
- Returns:
- HTTP line as a string
- Throws:
java.io.IOException
- if an I/O error occurs.
-
getMetrics
public HttpTransportMetrics getMetrics()
Deprecated.Description copied from interface:SessionInputBuffer
ReturnsHttpTransportMetrics
for this session buffer.- Specified by:
getMetrics
in interfaceSessionInputBuffer
- Returns:
- transport metrics.
-
-