public class HttpMethodReleaseInputStream
extends com.amazonaws.internal.SdkInputStream
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 the input stream. Additionally, this class attempts to release the connection and close the stream in this object's finalizer method, as a last resort to avoid leaking resources.
Important! This input stream must be completely consumed or closed to ensure the necessary cleanup operations can be performed.
Constructor and Description |
---|
HttpMethodReleaseInputStream(org.apache.http.HttpEntityEnclosingRequest httpMethod)
Constructs an input stream based on an
HttpMethod object
representing an HTTP connection. |
Modifier and Type | Method and Description |
---|---|
int |
available()
Standard input stream available method, except it ensures that
releaseConnection() is called if any errors are encountered from
the wrapped stream. |
void |
close()
Standard input stream close method, except it ensures that
releaseConnection() is called before the input stream is closed. |
org.apache.http.HttpEntityEnclosingRequest |
getHttpRequest()
Returns the underlying HttpMethod object that contains/manages the actual
HTTP connection.
|
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. |
public HttpMethodReleaseInputStream(org.apache.http.HttpEntityEnclosingRequest httpMethod)
HttpMethod
object
representing an HTTP connection. If a connection input stream is
available, this constructor wraps the underlying input stream and makes
that stream available. If no underlying connection is available, an empty
ByteArrayInputStream
is made available.httpMethod
- The HTTP method being executed, whose response content
is to be wrapped.public org.apache.http.HttpEntityEnclosingRequest getHttpRequest()
public int read() throws java.io.IOException
releaseConnection()
when the underlying input stream is consumed.read
in class java.io.InputStream
java.io.IOException
InputStream.read()
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
InputStream.read(byte[], int, int)
public int available() throws java.io.IOException
releaseConnection()
is called if any errors are encountered from
the wrapped stream.available
in class java.io.InputStream
java.io.IOException
InputStream.available()
public void close() throws java.io.IOException
releaseConnection()
is called before the input stream is closed.close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.InputStream
java.io.IOException
InputStream.close()
Copyright © 2010 Amazon Web Services, Inc. All Rights Reserved.