Top Description Fields Constructors Methods
org.apache.http.client.entity

public Class DecompressingEntity

extends HttpEntityWrapper
Class Inheritance
Known Direct Subclasses
org.apache.http.client.entity.DeflateDecompressingEntity, org.apache.http.client.entity.GzipDecompressingEntity
Imports
java.io.IOException, .InputStream, .OutputStream, org.apache.http.Header, .HttpEntity, org.apache.http.entity.HttpEntityWrapper, org.apache.http.util.Args

Common base class for decompressing HttpEntity implementations.
Since
4.4

Field Summary

Modifier and TypeField and Description
private static final int
BUFFER_SIZE

Default buffer size.

private InputStream
content

getContent() method must return the same InputStream instance when DecompressingEntity is wrapping a streaming entity.

private final InputStreamFactory
Inherited from org.apache.http.entity.HttpEntityWrapper:
wrappedEntity

Constructor Summary

AccessConstructor and Description
public
DecompressingEntity(final HttpEntity
the non-null HttpEntity to be wrapped
wrapped
,
final InputStreamFactory
factory to create decompressing stream.
inputStreamFactory
)

Creates a new DecompressingEntity.

Method Summary

Modifier and TypeMethod and Description
public InputStream
getContent()

Overrides org.apache.http.entity.HttpEntityWrapper.getContent.

Implements org.apache.http.HttpEntity.getContent.

Returns a content stream of the entity.
public Header
public long
private InputStream
public void
writeTo(final OutputStream
the output stream to write entity content to
outStream
)

Overrides org.apache.http.entity.HttpEntityWrapper.writeTo.

Implements org.apache.http.HttpEntity.writeTo.

Writes the entity content out to the output stream.
Inherited from org.apache.http.entity.HttpEntityWrapper:
consumeContentgetContentTypeisChunkedisRepeatableisStreaming

Field Detail

BUFFER_SIZEback to summary
private static final int BUFFER_SIZE

Default buffer size.

contentback to summary
private InputStream content

getContent() method must return the same InputStream instance when DecompressingEntity is wrapping a streaming entity.

inputStreamFactoryback to summary
private final InputStreamFactory inputStreamFactory

Constructor Detail

DecompressingEntityback to summary
public DecompressingEntity(final HttpEntity wrapped, final InputStreamFactory inputStreamFactory)

Creates a new DecompressingEntity.

Parameters
wrapped:HttpEntity

the non-null HttpEntity to be wrapped

inputStreamFactory:InputStreamFactory

factory to create decompressing stream.

Method Detail

getContentback to summary
public InputStream getContent() throws IOException

Overrides org.apache.http.entity.HttpEntityWrapper.getContent.

Implements org.apache.http.HttpEntity.getContent.

Doc from org.apache.http.HttpEntity.getContent.

Returns a content stream of the entity. Repeatable entities are expected to create a new instance of InputStream for each invocation of this method and therefore can be consumed multiple times. Entities that are not repeatable are expected to return the same InputStream instance and therefore may not be consumed more than once.

Important Note

Please note all entity implementations must ensure that all allocated resources are properly deallocated after the InputStream#close() method is invoked.

Returns:InputStream

content stream of the entity.

Annotations
@Override
Exceptions
IOException:
if the stream could not be created
getContentEncodingback to summary
public Header getContentEncoding()

Overrides org.apache.http.entity.HttpEntityWrapper.getContentEncoding.

Implements org.apache.http.HttpEntity.getContentEncoding.

Doc from org.apache.http.HttpEntity.getContentEncoding.

Obtains the Content-Encoding header, if known. This is the header that should be used when sending the entity, or the one that was received with the entity. Wrapping entities that modify the content encoding should adjust this header accordingly.

Returns:Header

the Content-Encoding header for this entity, or null if the content encoding is unknown

Annotations
@Override
getContentLengthback to summary
public long getContentLength()

Overrides org.apache.http.entity.HttpEntityWrapper.getContentLength.

Implements org.apache.http.HttpEntity.getContentLength.

Doc from org.apache.http.HttpEntity.getContentLength.

Tells the length of the content, if known.

Returns:long

the number of bytes of the content, or a negative number if unknown. If the content length is known but exceeds Long.MAX_VALUE, a negative number is returned.

Annotations
@Override
getDecompressingStreamback to summary
private InputStream getDecompressingStream() throws IOException
writeToback to summary
public void writeTo(final OutputStream outStream) throws IOException

Overrides org.apache.http.entity.HttpEntityWrapper.writeTo.

Implements org.apache.http.HttpEntity.writeTo.

Doc from org.apache.http.HttpEntity.writeTo.

Writes the entity content out to the output stream.

Important Note

Please note all entity implementations must ensure that all allocated resources are properly deallocated when this method returns.

Parameters
outStream:OutputStream

the output stream to write entity content to

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs