public final class HTTPResponseCompressor : ChannelDuplexHandler

A HTTPResponseCompressor is a duplex channel handler that handles automatic streaming compression of HTTP responses. It respects the client’s Accept-Encoding preferences, including q-values if present, and ensures that clients are served the compression algorithm that works best for them.

This compressor supports gzip and deflate. It works best if many writes are made between flushes.

Note that this compressor performs the compression on the event loop thread. This means that compressing some resources, particularly those that do not benefit from compression or that could have been compressed ahead-of-time instead of dynamically, could be a waste of CPU time and latency for relatively minimal benefit. This channel handler should be present in the pipeline only for dynamically-generated and highly-compressible content, which will see the biggest benefits from streaming compression.