Class HttpContentEncoder

All Implemented Interfaces:
ChannelHandler, ChannelInboundHandler, ChannelOutboundHandler
Direct Known Subclasses:
HttpContentCompressor

public abstract class HttpContentEncoder extends MessageToMessageCodec<HttpRequest,HttpObject>
Encodes the content of the outbound HttpResponse and HttpContent. The original content is replaced with the new content encoded by the EmbeddedChannel, which is created by beginEncode(HttpResponse, String). Once encoding is finished, the value of the 'Content-Encoding' header is set to the target content encoding, as returned by beginEncode(HttpResponse, String). Also, the 'Content-Length' header is updated to the length of the encoded content. If there is no supported or allowed encoding in the corresponding HttpRequest's "Accept-Encoding" header, beginEncode(HttpResponse, String) should return null so that no encoding occurs (i.e. pass-through).

Please note that this is an abstract class. You have to extend this class and implement beginEncode(HttpResponse, String) properly to make this class functional. For example, refer to the source code of HttpContentCompressor.

This handler must be placed after HttpObjectEncoder in the pipeline so that this handler can intercept HTTP responses before HttpObjectEncoder converts them into ByteBufs.