Class 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 expects HttpObjects it should be added after HttpServerCodec but before any other handlers that might send a HttpResponse.

      ChannelPipeline p = ...;
      ...
      p.addLast("serverCodec", new HttpServerCodec());
      p.addLast("httpKeepAlive", new HttpServerKeepAliveHandler());
      p.addLast("aggregator", new HttpObjectAggregator(1048576));
      ...
      p.addLast("handler", new HttpRequestHandler());