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, org.apache.hc.core5.http.EntityDetails, org.apache.hc.core5.http.HttpEntity
public final class CompressingEntity
extends org.apache.hc.core5.http.io.entity.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
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Stringprivate final org.apache.hc.core5.io.IOFunction<OutputStream, OutputStream> -
Constructor Summary
ConstructorsConstructorDescriptionCompressingEntity(org.apache.hc.core5.http.HttpEntity src, String coding, org.apache.hc.core5.io.IOFunction<OutputStream, OutputStream> encoder) -
Method Summary
Methods inherited from class org.apache.hc.core5.http.io.entity.HttpEntityWrapper
close, getContentType, getTrailerNames, getTrailers, isRepeatable, isStreaming, toString
-
Field Details
-
encoder
-
coding
-
-
Constructor Details
-
CompressingEntity
public CompressingEntity(org.apache.hc.core5.http.HttpEntity src, String coding, org.apache.hc.core5.io.IOFunction<OutputStream, OutputStream> encoder)
-
-
Method Details
-
getContentEncoding
- Specified by:
getContentEncodingin interfaceorg.apache.hc.core5.http.EntityDetails- Overrides:
getContentEncodingin classorg.apache.hc.core5.http.io.entity.HttpEntityWrapper
-
getContentLength
public long getContentLength()- Specified by:
getContentLengthin interfaceorg.apache.hc.core5.http.EntityDetails- Overrides:
getContentLengthin classorg.apache.hc.core5.http.io.entity.HttpEntityWrapper
-
isChunked
public boolean isChunked()- Specified by:
isChunkedin interfaceorg.apache.hc.core5.http.EntityDetails- Overrides:
isChunkedin classorg.apache.hc.core5.http.io.entity.HttpEntityWrapper
-
getContent
- Specified by:
getContentin interfaceorg.apache.hc.core5.http.HttpEntity- Overrides:
getContentin classorg.apache.hc.core5.http.io.entity.HttpEntityWrapper
-
writeTo
- Specified by:
writeToin interfaceorg.apache.hc.core5.http.HttpEntity- Overrides:
writeToin classorg.apache.hc.core5.http.io.entity.HttpEntityWrapper- Throws:
IOException
-