public abstract class AbstractInputStreamContent extends Objectimplements HttpContent
The type field is required. Subclasses should implement the HttpContent, getInputStream(), and HttpContent for their specific type of input stream. By default, all content is read from the input stream. If instead you want to limit the maximum amount of content read from the input stream, you may use ByteStreams.
Implementations don't need to be thread-safe.
| Constructor and Description |
|---|
AbstractInputStreamContent(String
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
getCloseInputStream()
Returns whether the input stream should be closed at the end of
writeTo(java.io.OutputStream).
|
abstract InputStream |
getInputStream()
Return an input stream for the specific implementation type of
AbstractInputStreamContent.
|
String |
getType()
Returns the content type or
null for none.
|
AbstractInputStreamContent |
setCloseInputStream(boolean closeInputStream)
Sets whether the input stream should be closed at the end of
writeTo(java.io.OutputStream).
|
AbstractInputStreamContent |
setType(String
Sets the content type or
null for none.
|
void |
writeTo(OutputStream
Writes the byte content to the given output stream.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetLength, retrySupportedpublic AbstractInputStreamContent(Stringtype)
type - Content type or
null for none
public abstract InputStreamgetInputStream() throws IOException
AbstractInputStreamContent. If the specific implementation will return
true for
HttpContent.retrySupported() this should be a factory function which will create a new
InputStream from the source data whenever invoked.
IOException
public void writeTo(OutputStreamout) throws IOException
StreamingContent
Implementations must not close the output stream, and instead should flush the output stream. Some callers may assume that the the output stream has not been closed, and will fail to work if it has been closed.
writeTo in interface
HttpContent
writeTo in interface
StreamingContent
out - output stream
IOException
public StringgetType()
HttpContent
null for none.
public final boolean getCloseInputStream()
writeTo(java.io.OutputStream). Default is
true.
public AbstractInputStreamContentsetType(String type)
null for none. Subclasses should override by calling super.
public AbstractInputStreamContentsetCloseInputStream(boolean closeInputStream)
writeTo(java.io.OutputStream). Default is
true. Subclasses should override by calling super.