Package org.apache.http.conn
Class EofSensorInputStream
java.lang.Object
java.io.InputStream
org.apache.http.conn.EofSensorInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable,ConnectionReleaseTrigger
A stream wrapper that triggers actions on
close() and EOF.
Primarily used to auto-release an underlying managed connection when the response
body is consumed or no longer needed.- Since:
- 4.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionEofSensorInputStream(InputStream in, EofSensorWatcher watcher) Creates a new EOF sensor. -
Method Summary
Methods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Constructor Details
-
EofSensorInputStream
Creates a new EOF sensor. If no watcher is passed, the underlying stream will simply be closed when EOF is detected orcloseis called. Otherwise, the watcher decides whether the underlying stream should be closed before detaching from it.- Parameters:
in- the wrapped streamwatcher- the watcher for events, ornullfor auto-close behavior without notification
-
-
Method Details
-
read
- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
available
- Overrides:
availablein classInputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
releaseConnection
Same asclose().- Specified by:
releaseConnectionin interfaceConnectionReleaseTrigger- Throws:
IOException- in case of an IO problem. The connection will be released anyway.
-
abortConnection
Aborts this stream. This is a special version ofclose()which prevents re-use of the underlying connection, if any. Calling this method indicates that there should be no attempt to read until the end of the stream.- Specified by:
abortConnectionin interfaceConnectionReleaseTrigger- Throws:
IOException- in case of an IO problem. The connection will be released anyway.
-