org.apache.hc.client5.http.entity.compress

## Class CompressingEntity

- java.lang.Object
- - org.apache.hc.core5.http.io.entity.HttpEntityWrapper
  - - org.apache.hc.client5.http.entity.compress.CompressingEntity

All Implemented Interfaces:
  Closeable, AutoCloseable, EntityDetails, HttpEntity

    public final class CompressingEntity
    extends HttpEntityWrapper

Streaming wrapper that compresses the enclosed `HttpEntity` on write.

The actual compressor is supplied as an `IOFunction`<OutputStream,OutputStream> and is resolved by the caller (for example via reflective factories). This keeps compression back-ends fully optional and avoids hard classpath dependencies.

The entity reports the configured `Content-Encoding` token and streams the content; length is unknown (`-1`), and the entity is chunked.

Since:
  5.6

### Constructor Summary

Constructors
Constructor and Description
`CompressingEntity(HttpEntity src, String coding, IOFunction<OutputStream,OutputStream> encoder)`

### Method Summary

All Methods Instance Methods Concrete Methods
`InputStream` `getContent()`
`String` `getContentEncoding()`
`long` `getContentLength()`
`boolean` `isChunked()`
`void` `writeTo(OutputStream out)`

### Methods inherited from class org.apache.hc.core5.http.io.entity.HttpEntityWrapper

`close, getContentType, getTrailerNames, getTrailers, isRepeatable, isStreaming, toString`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### CompressingEntity

    public CompressingEntity(HttpEntity src,
                             String coding,
                             IOFunction<OutputStream,OutputStream> encoder)

### Method Detail

#### getContentEncoding

    public String getContentEncoding()

Specified by:
  `getContentEncoding` in interface `EntityDetails`
Overrides:
  `getContentEncoding` in class `HttpEntityWrapper`

#### getContentLength

    public long getContentLength()

Specified by:
  `getContentLength` in interface `EntityDetails`
Overrides:
  `getContentLength` in class `HttpEntityWrapper`

#### isChunked

    public boolean isChunked()

Specified by:
  `isChunked` in interface `EntityDetails`
Overrides:
  `isChunked` in class `HttpEntityWrapper`

#### getContent

    public InputStream getContent()

Specified by:
  `getContent` in interface `HttpEntity`
Overrides:
  `getContent` in class `HttpEntityWrapper`

#### writeTo

    public void writeTo(OutputStream out)
                 throws IOException

Specified by:
  `writeTo` in interface `HttpEntity`
Overrides:
  `writeTo` in class `HttpEntityWrapper`
Throws:
  `IOException`