public final class DeflatingZstdEntityProducer extends Object implements AsyncEntityProducer
AsyncEntityProducer that compresses the bytes produced by a delegate entity
into a single Zstandard (zstd) frame
on the fly.
This producer wraps a AsyncEntityProducer and
performs streaming, ByteBuffer-to-ByteBuffer compression as the delegate writes to the
provided DataStreamChannel. No InputStream
is used in the client pipeline.
Metadata reported by this producer:
getContentEncoding() returns "zstd".getContentLength() returns -1 (unknown after compression).isChunked() returns true (requests are typically sent chunked).Behavior
ByteBuffers and written only when the channel accepts bytes.
When DataStreamChannel.write(...) returns 0, the producer pauses and
requests another output turn.endStream(), this producer emits
the zstd frame epilogue and then calls DataStreamChannel.endStream().Content-Encoding: zstd on
the request if required by the server. Content length is not known in advance.releaseResources() to free native compressor resources.Constructors
DeflatingZstdEntityProducer(delegate) – uses a default compression level.DeflatingZstdEntityProducer(delegate, level) – explicitly sets the zstd level.Thread-safety
Not thread-safe; one instance per message exchange.
Runtime dependency
Requires com.github.luben:zstd-jni on the classpath.
InflatingZstdDataConsumer,
BasicRequestProducer,
StringAsyncEntityProducer,
ContentCompressionAsyncExec| Constructor and Description |
|---|
DeflatingZstdEntityProducer(AsyncEntityProducer delegate) |
DeflatingZstdEntityProducer(AsyncEntityProducer delegate,
int level) |
| Modifier and Type | Method and Description |
|---|---|
int |
available() |
void |
failed(Exception cause) |
String |
getContentEncoding() |
long |
getContentLength() |
String |
getContentType() |
Set<String> |
getTrailerNames() |
boolean |
isChunked() |
boolean |
isRepeatable() |
void |
produce(DataStreamChannel chan) |
void |
releaseResources() |
public DeflatingZstdEntityProducer(AsyncEntityProducer delegate)
public DeflatingZstdEntityProducer(AsyncEntityProducer delegate, int level)
public boolean isRepeatable()
isRepeatable in interface AsyncEntityProducerpublic long getContentLength()
getContentLength in interface EntityDetailspublic String getContentType()
getContentType in interface EntityDetailspublic String getContentEncoding()
getContentEncoding in interface EntityDetailspublic boolean isChunked()
isChunked in interface EntityDetailspublic Set<String> getTrailerNames()
getTrailerNames in interface EntityDetailspublic int available()
available in interface AsyncDataProducerpublic void produce(DataStreamChannel chan) throws IOException
produce in interface AsyncDataProducerIOExceptionpublic void failed(Exception cause)
failed in interface AsyncEntityProducerpublic void releaseResources()
releaseResources in interface ResourceHolderCopyright © 1999–2021 The Apache Software Foundation. All rights reserved.