Class SmartHttpContentCompressor

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
io.netty.handler.codec.MessageToMessageCodec<io.netty.handler.codec.http.HttpRequest,io.netty.handler.codec.http.HttpObject>
io.netty.handler.codec.http.HttpContentEncoder
io.netty.handler.codec.http.HttpContentCompressor
io.micronaut.http.server.netty.SmartHttpContentCompressor
All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler, io.netty.channel.ChannelOutboundHandler

@Internal public class SmartHttpContentCompressor extends io.netty.handler.codec.http.HttpContentCompressor
An extension of HttpContentCompressor that skips encoding if the content type is not compressible or if the content is too small.
Since:
1.0
Author:
James Kleeh
  • Nested Class Summary

    Nested classes/interfaces inherited from class io.netty.handler.codec.http.HttpContentEncoder

    io.netty.handler.codec.http.HttpContentEncoder.Result

    Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

    io.netty.channel.ChannelHandler.Sharable
  • Method Summary

    Modifier and Type
    Method
    Description
    protected io.netty.handler.codec.http.HttpContentEncoder.Result
    beginEncode(io.netty.handler.codec.http.HttpResponse headers, String acceptEncoding)
     
    protected void
    encode(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.HttpObject msg, List<Object> out)
     
    boolean
    shouldSkip(io.netty.handler.codec.http.HttpResponse response)
    Determines if encoding should occur based on the response.

    Methods inherited from class io.netty.handler.codec.http.HttpContentCompressor

    determineEncoding, determineWrapper, handlerAdded

    Methods inherited from class io.netty.handler.codec.http.HttpContentEncoder

    acceptOutboundMessage, channelInactive, decode, handlerRemoved

    Methods inherited from class io.netty.handler.codec.MessageToMessageCodec

    acceptInboundMessage, channelRead, write

    Methods inherited from class io.netty.channel.ChannelDuplexHandler

    bind, close, connect, deregister, disconnect, flush, read

    Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

    channelActive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered

    Methods inherited from class io.netty.channel.ChannelHandlerAdapter

    ensureNotSharable, isSharable

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • shouldSkip

      public boolean shouldSkip(io.netty.handler.codec.http.HttpResponse response)
      Determines if encoding should occur based on the response.
      Parameters:
      response - The response
      Returns:
      True if the content should not be compressed
    • encode

      protected void encode(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.HttpObject msg, List<Object> out) throws Exception
      Overrides:
      encode in class io.netty.handler.codec.http.HttpContentEncoder
      Throws:
      Exception
    • beginEncode

      protected io.netty.handler.codec.http.HttpContentEncoder.Result beginEncode(io.netty.handler.codec.http.HttpResponse headers, String acceptEncoding) throws Exception
      Overrides:
      beginEncode in class io.netty.handler.codec.http.HttpContentCompressor
      Throws:
      Exception