public interface HttpEntity
responses, where they are optional.
There are three distinct types of entities in HttpCore,
depending on where their
Streamedentities are generally not
|Modifier and Type||Method and Description|
Returns a content stream of the entity.
Obtains the Content-Encoding header, if known.
Tells the length of the content, if known.
Obtains the Content-Type header, if known.
Tells about chunked encoding for this entity.
Tells if the entity is capable of producing its data more than once.
Tells whether this entity depends on an underlying stream.
Writes the entity content out to the output stream.
The behavior of wrapping entities is implementation dependent, but should respect the primary purpose.
trueif chunked encoding is preferred for this entity, or
falseif it is not
Long.MAX_VALUE, a negative number is returned.
nullif the content type is unknown
nullif the content encoding is unknown
InputStream getContent() throws IOException, IllegalStateException
Repeatableentities are expected to create a new instance of
InputStreamfor each invocation of this method and therefore can be consumed multiple times. Entities that are not
repeatableare expected to return the same
InputStreaminstance and therefore may not be consumed more than once.
IMPORTANT: Please note all entity implementations must ensure that
all allocated resources are properly deallocated after
InputStream.close() method is invoked.
void writeTo(OutputStream outstream) throws IOException
IMPORTANT: Please note all entity implementations must ensure that all allocated resources are properly deallocated when this method returns.
outstream- the output stream to write entity content to
IOException- if an I/O error occurs
true. Self-contained entities should return
false. Wrapping entities should delegate this call to the wrapped entity.
trueif the entity content is streamed,
@Deprecated void consumeContent() throws IOException
InputStream.close()on the input stream returned by
This method is called to indicate that the content of this entity is no longer required. All entity implementations are expected to release all allocated resources as a result of this method invocation. Content streaming entities are also expected to dispose of the remaining content, if any. Wrapping entities should delegate this call to the wrapped entity.
This method is of particular importance for entities being
received from a
connection. The entity
needs to be consumed completely in order to re-use the connection
Copyright © 2005–2014 The Apache Software Foundation. All rights reserved.