Top Description Fields Constructors Methods
org.apache.hc.client5.http.entity

public Class DecompressingEntity

extends HttpEntityWrapper
Class Inheritance
Known Direct Subclasses
org.apache.hc.client5.http.entity.DeflateDecompressingEntity, org.apache.hc.client5.http.entity.GzipDecompressingEntity, org.apache.hc.client5.http.entity.BrotliDecompressingEntity
Imports
java.io.IOException, .InputStream, .OutputStream, org.apache.hc.core5.http.HttpEntity, org.apache.hc.core5.http.io.entity.HttpEntityWrapper, org.apache.hc.core5.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

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
)

Constructs a new DecompressingEntity.

Method Summary

Modifier and TypeMethod and Description
public InputStream
public String
public long
private InputStream
public void
writeTo(final OutputStream
the output stream to write entity content to
outStream
)

Overrides org.apache.hc.core5.http.io.entity.HttpEntityWrapper.writeTo.

Implements org.apache.hc.core5.http.HttpEntity.writeTo.

Writes the entity content out to the output stream.
Inherited from org.apache.hc.core5.http.io.entity.HttpEntityWrapper:
closegetContentTypegetTrailerNamesgetTrailersisChunkedisRepeatableisStreamingtoString

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)

Constructs 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.hc.core5.http.io.entity.HttpEntityWrapper.getContent.

Implements org.apache.hc.core5.http.HttpEntity.getContent.

Doc from org.apache.hc.core5.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.

If this entity belongs to an incoming HTTP message, calling InputStream#close() on the returned InputStream will try to consume the complete entity content to keep the connection alive. In cases where this is undesired, e.g. when only a small part of the content is relevant and consuming the complete entity content would be too inefficient, only the HTTP message from which this entity was obtained should be closed (if supported).

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 String getContentEncoding()

Overrides org.apache.hc.core5.http.io.entity.HttpEntityWrapper.getContentEncoding.

Implements org.apache.hc.core5.http.EntityDetails.getContentEncoding.

Doc from org.apache.hc.core5.http.EntityDetails.getContentEncoding.

Returns content encoding of the entity, if known.

Annotations
@Override
getContentLengthback to summary
public long getContentLength()

Overrides org.apache.hc.core5.http.io.entity.HttpEntityWrapper.getContentLength.

Implements org.apache.hc.core5.http.EntityDetails.getContentLength.

Doc from org.apache.hc.core5.http.EntityDetails.getContentLength.

Returns length of the entity, if known.

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

Overrides org.apache.hc.core5.http.io.entity.HttpEntityWrapper.writeTo.

Implements org.apache.hc.core5.http.HttpEntity.writeTo.

Doc from org.apache.hc.core5.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