|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.InputStream
org.jets3t.service.impl.rest.httpclient.HttpMethodReleaseInputStream
public class HttpMethodReleaseInputStream
Utility class to wrap InputStreams obtained from an HttpClient library's HttpMethod object, and ensure the stream and HTTP connection is cleaned up properly.
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 Summary | |
---|---|
HttpMethodReleaseInputStream(org.apache.commons.httpclient.HttpMethod httpMethod)
Constructs an input stream based on an HttpMethod object representing an HTTP connection. |
Method Summary | |
---|---|
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. |
java.io.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. |
Methods inherited from class java.io.InputStream |
---|
mark, markSupported, read, reset, skip |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public 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
- Method Detail |
---|
public org.apache.commons.httpclient.HttpMethod getHttpMethod()
public int read() throws java.io.IOException
releaseConnection()
when the underlying
input stream is consumed.
read
in class java.io.InputStream
java.io.IOException
public int read(byte[] b, int off, int len) throws java.io.IOException
releaseConnection()
when the underlying
input stream is consumed.
read
in class java.io.InputStream
java.io.IOException
public int available() throws java.io.IOException
available
in class java.io.InputStream
java.io.IOException
public void close() throws java.io.IOException
releaseConnection()
is called
before the input stream is closed.
close
in interface java.io.Closeable
close
in class java.io.InputStream
java.io.IOException
public java.io.InputStream getWrappedInputStream()
getWrappedInputStream
in interface InputStreamWrapper
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |