Class HstsHandler
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelOutboundHandlerAdapter
-
- com.github.fmjsjx.libnetty.http.server.HstsHandler
-
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelOutboundHandler
@Sharable public class HstsHandler extends io.netty.channel.ChannelOutboundHandlerAdapterA specialChannelOutboundHandlerwhich sets the HTTPStrict-Transport-Securityheader automatically.- Since:
- 1.1
-
-
Constructor Summary
Constructors Constructor Description HstsHandler()HstsHandler(long maxAge)Constructs a newHstsHandlerinstance with the specifiedmaxAge.HstsHandler(java.time.Duration maxAge)Constructs a newHstsHandlerinstance with the specifiedmaxAge.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static HstsHandlergetInstance()Returns the singleton instance with defaultmax-age.voidwrite(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
-
-
-
-
Constructor Detail
-
HstsHandler
public HstsHandler()
-
HstsHandler
public HstsHandler(long maxAge)
Constructs a newHstsHandlerinstance with the specifiedmaxAge.- Parameters:
maxAge- themax-agevalue in seconds
-
HstsHandler
public HstsHandler(java.time.Duration maxAge)
Constructs a newHstsHandlerinstance with the specifiedmaxAge.- Parameters:
maxAge- themax-agevalue
-
-
Method Detail
-
getInstance
public static final HstsHandler getInstance()
Returns the singleton instance with defaultmax-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:
writein interfaceio.netty.channel.ChannelOutboundHandler- Overrides:
writein classio.netty.channel.ChannelOutboundHandlerAdapter- Throws:
java.lang.Exception
-
-