Closeable, AutoCloseable, InputStreamWrapperpublic class HttpMethodReleaseInputStream extends InputStream implements InputStreamWrapper
This input stream wrapper is used to ensure that input streams obtained through HttpClient connections are cleaned up correctly once the caller has read all the contents of the connection's input stream, or closed that input stream.
Important! This input stream must be completely consumed or closed to ensure the necessary cleanup operations can be performed.
| Constructor | Description |
|---|---|
HttpMethodReleaseInputStream(org.apache.commons.httpclient.HttpMethod httpMethod) |
Constructs an input stream based on an
HttpMethod object representing an HTTP connection. |
| Modifier and Type | Method | Description |
|---|---|---|
int |
available() |
|
void |
close() |
Standard input stream close method, except it ensures that
releaseConnection() is called
before the input stream is closed. |
org.apache.commons.httpclient.HttpMethod |
getHttpMethod() |
Returns the underlying HttpMethod object that contains/manages the actual HTTP connection.
|
InputStream |
getWrappedInputStream() |
|
int |
read() |
Standard input stream read method, except it calls
releaseConnection() when the underlying
input stream is consumed. |
int |
read(byte[] b,
int off,
int len) |
Standard input stream read method, except it calls
releaseConnection() when the underlying
input stream is consumed. |
mark, markSupported, read, readAllBytes, readNBytes, reset, skip, transferTopublic HttpMethodReleaseInputStream(org.apache.commons.httpclient.HttpMethod httpMethod)
HttpMethod object representing an HTTP connection.
If a connection input stream is available, this constructor wraps the underlying input stream
in an InterruptableInputStream and makes that stream available. If no underlying connection
is available, an empty ByteArrayInputStream is made available.httpMethod - public org.apache.commons.httpclient.HttpMethod getHttpMethod()
public int read()
throws IOException
releaseConnection() when the underlying
input stream is consumed.read in class InputStreamIOExceptionpublic int read(byte[] b,
int off,
int len)
throws IOException
releaseConnection() when the underlying
input stream is consumed.read in class InputStreamIOExceptionpublic int available()
throws IOException
available in class InputStreamIOExceptionpublic void close()
throws IOException
releaseConnection() is called
before the input stream is closed.close in interface AutoCloseableclose in interface Closeableclose in class InputStreamIOExceptionpublic InputStream getWrappedInputStream()
getWrappedInputStream in interface InputStreamWrapper