Class CompressingEntity
- java.lang.Object
-
- org.apache.hc.core5.http.io.entity.HttpEntityWrapper
-
- org.apache.hc.client5.http.entity.compress.CompressingEntity
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.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.HttpEntityWrapperStreaming wrapper that compresses the enclosedHttpEntityon 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-Encodingtoken and streams the content; length is unknown (-1), and the entity is chunked.- Since:
- 5.6
-
-
Constructor Summary
Constructors Constructor Description CompressingEntity(org.apache.hc.core5.http.HttpEntity src, java.lang.String coding, org.apache.hc.core5.io.IOFunction<java.io.OutputStream,java.io.OutputStream> encoder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.InputStreamgetContent()java.lang.StringgetContentEncoding()longgetContentLength()booleanisChunked()voidwriteTo(java.io.OutputStream out)
-
-
-
Method Detail
-
getContentEncoding
public java.lang.String 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
public java.io.InputStream getContent()
- Specified by:
getContentin interfaceorg.apache.hc.core5.http.HttpEntity- Overrides:
getContentin classorg.apache.hc.core5.http.io.entity.HttpEntityWrapper
-
writeTo
public void writeTo(java.io.OutputStream out) throws java.io.IOException- Specified by:
writeToin interfaceorg.apache.hc.core5.http.HttpEntity- Overrides:
writeToin classorg.apache.hc.core5.http.io.entity.HttpEntityWrapper- Throws:
java.io.IOException
-
-