public class HttpEntityWrapper extends java.lang.Object implements HttpEntity
wrappedEntity
and delegates all
calls to it. Implementations of wrapping entities can derive
from this class and need to override only those methods that
should not be delegated to the wrapped entity.Modifier and Type | Field and Description |
---|---|
protected HttpEntity |
wrappedEntity
The wrapped entity.
|
Constructor and Description |
---|
HttpEntityWrapper(HttpEntity wrapped)
Creates a new entity wrapper.
|
Modifier and Type | Method and Description |
---|---|
void |
consumeContent()
TODO: The name of this method is misnomer.
|
java.io.InputStream |
getContent()
Creates a new InputStream object of the entity.
|
Header |
getContentEncoding()
Obtains the Content-Encoding header, if known.
|
long |
getContentLength()
Tells the length of the content, if known.
|
Header |
getContentType()
Obtains the Content-Type header, if known.
|
boolean |
isChunked()
Tells about chunked encoding for this entity.
|
boolean |
isRepeatable()
Tells if the entity is capable of producing its data more than once.
|
boolean |
isStreaming()
Tells whether this entity depends on an underlying stream.
|
void |
writeTo(java.io.OutputStream outstream)
Writes the entity content to the output stream.
|
protected HttpEntity wrappedEntity
public HttpEntityWrapper(HttpEntity wrapped)
wrapped
- the entity to wrappublic boolean isRepeatable()
HttpEntity
isRepeatable
in interface HttpEntity
public boolean isChunked()
HttpEntity
isChunked
in interface HttpEntity
true
if chunked encoding is preferred for this
entity, or false
if it is notpublic long getContentLength()
HttpEntity
getContentLength
in interface HttpEntity
Long.MAX_VALUE
,
a negative number is returned.public Header getContentType()
HttpEntity
getContentType
in interface HttpEntity
null
if the content type is unknownpublic Header getContentEncoding()
HttpEntity
getContentEncoding
in interface HttpEntity
null
if the content encoding is unknownpublic java.io.InputStream getContent() throws java.io.IOException
HttpEntity
repeatable
will throw an exception if this method is called multiple times.getContent
in interface HttpEntity
java.io.IOException
- if the stream could not be createdpublic void writeTo(java.io.OutputStream outstream) throws java.io.IOException
HttpEntity
writeTo
in interface HttpEntity
outstream
- the output stream to write entity content tojava.io.IOException
- if an I/O error occurspublic boolean isStreaming()
HttpEntity
true
until the
content has been consumed, false
afterwards.
Self-contained entities should return false
.
Wrapping entities should delegate this call to the wrapped entity.
getContent
has been read to EOF,
or after consumeContent
has been called.
If a streamed entity can not detect whether the stream has been
read to EOF, it should return true
until
consumeContent
is called.isStreaming
in interface HttpEntity
true
if the entity content is streamed and
not yet consumed, false
otherwisepublic void consumeContent() throws java.io.IOException
HttpEntity
connection
. The entity
needs to be consumed completely in order to re-use the connection
with keep-alive.consumeContent
in interface HttpEntity
java.io.IOException
- if an I/O error occurs.
This indicates that connection keep-alive is not possible.