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

public Class GzipCompressingEntity

extends HttpEntityWrapper
Class Inheritance
Imports
java.io.IOException, .InputStream, .OutputStream, java.util.zip.GZIPOutputStream, org.apache.hc.core5.http.HttpEntity, org.apache.hc.core5.http.io.entity.HttpEntityWrapper, org.apache.hc.core5.util.Args

Wrapping entity that compresses content when writing.
Since
4.0

Field Summary

Modifier and TypeField and Description
private static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public InputStream
public String
public long
public boolean
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:
closegetContentTypegetTrailerNamesgetTrailersisRepeatableisStreamingtoString

Field Detail

GZIP_CODECback to summary
private static final String GZIP_CODEC

Constructor Detail

GzipCompressingEntityback to summary
public GzipCompressingEntity(final HttpEntity entity)

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
isChunkedback to summary
public boolean isChunked()

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

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

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

Returns chunked transfer hint for this entity.

The behavior of wrapping entities is implementation dependent, but should respect the primary purpose.

Annotations
@Override
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