- java.lang.Object
-
- io.netty5.handler.codec.http.HttpServerKeepAliveHandler
-
- All Implemented Interfaces:
ChannelHandler
public class HttpServerKeepAliveHandler extends Object implements ChannelHandler
HttpServerKeepAliveHandler helps close persistent connections when appropriate.The server channel is expected to set the proper 'Connection' header if it can handle persistent connections.
HttpServerKeepAliveHandler
will automatically close the channel for any LastHttpContent that corresponds to a client request for closing the connection, or if the HttpResponse associated with that LastHttpContent requested closing the connection or didn't have a self defined message length.Since
HttpServerKeepAliveHandler
expectsHttpObject
s it should be added afterHttpServerCodec
but before any other handlers that might send aHttpResponse
.ChannelPipeline
p = ...; ... p.addLast("serverCodec", newHttpServerCodec
()); p.addLast("httpKeepAlive", newHttpServerKeepAliveHandler
()); p.addLast("aggregator", newHttpObjectAggregator
(1048576)); ... p.addLast("handler", new HttpRequestHandler());
-
-
Constructor Summary
Constructors Constructor Description HttpServerKeepAliveHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
channelRead(ChannelHandlerContext ctx, Object msg)
Invoked when the currentChannel
has read a message from the peer.Future<Void>
write(ChannelHandlerContext ctx, Object msg)
Called once a write operation is made.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty5.channel.ChannelHandler
bind, channelActive, channelExceptionCaught, channelInactive, channelInboundEvent, channelReadComplete, channelRegistered, channelShutdown, channelUnregistered, channelWritabilityChanged, close, connect, deregister, disconnect, flush, handlerAdded, handlerRemoved, isSharable, pendingOutboundBytes, read, register, sendOutboundEvent, shutdown
-
-
-
-
Method Detail
-
channelRead
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
Description copied from interface:ChannelHandler
Invoked when the currentChannel
has read a message from the peer.- Specified by:
channelRead
in interfaceChannelHandler
- Throws:
Exception
-
write
public Future<Void> write(ChannelHandlerContext ctx, Object msg)
Description copied from interface:ChannelHandler
Called once a write operation is made. The write operation will write the messages through theChannelPipeline
. Those are then ready to be flushed to the actualChannel
onceChannel.flush()
is called.- Specified by:
write
in interfaceChannelHandler
- Parameters:
ctx
- theChannelHandlerContext
for which the write operation is mademsg
- the message to write- Returns:
- the
Future
which will be notified once the operation completes.
-
-