Class HstsHandler

  • All Implemented Interfaces:
    io.netty.channel.ChannelHandler, io.netty.channel.ChannelOutboundHandler

    @Sharable
    public class HstsHandler
    extends io.netty.channel.ChannelOutboundHandlerAdapter
    A special ChannelOutboundHandler which sets the HTTP Strict-Transport-Security header automatically.
    Since:
    1.1
    • Nested Class Summary

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

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

      Constructors 
      Constructor Description
      HstsHandler()
      Constructs a new HstsHandler instance with default max-age (86400).
      HstsHandler​(long maxAge)
      Constructs a new HstsHandler instance with the specified maxAge.
      HstsHandler​(java.time.Duration maxAge)
      Constructs a new HstsHandler instance with the specified maxAge.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static HstsHandler getInstance()
      Returns the singleton instance with default max-age.
      void write​(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object msg, io.netty.channel.ChannelPromise promise)  
      • Methods inherited from class io.netty.channel.ChannelOutboundHandlerAdapter

        bind, close, connect, deregister, disconnect, flush, read
      • Methods inherited from class io.netty.channel.ChannelHandlerAdapter

        ensureNotSharable, exceptionCaught, handlerAdded, handlerRemoved, isSharable
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface io.netty.channel.ChannelHandler

        exceptionCaught, handlerAdded, handlerRemoved
    • Constructor Detail

      • HstsHandler

        public HstsHandler()
        Constructs a new HstsHandler instance with default max-age (86400).
      • HstsHandler

        public HstsHandler​(long maxAge)
        Constructs a new HstsHandler instance with the specified maxAge.
        Parameters:
        maxAge - the max-age value in seconds
      • HstsHandler

        public HstsHandler​(java.time.Duration maxAge)
        Constructs a new HstsHandler instance with the specified maxAge.
        Parameters:
        maxAge - the max-age value
    • Method Detail

      • getInstance

        public static final HstsHandler getInstance()
        Returns the singleton instance with default max-age.
        Returns:
        the singleton instance with default max-age
      • write

        public void write​(io.netty.channel.ChannelHandlerContext ctx,
                          java.lang.Object msg,
                          io.netty.channel.ChannelPromise promise)
                   throws java.lang.Exception
        Specified by:
        write in interface io.netty.channel.ChannelOutboundHandler
        Overrides:
        write in class io.netty.channel.ChannelOutboundHandlerAdapter
        Throws:
        java.lang.Exception