Search in sources :

Example 1 with HttpBaseHandler

use of com.duangframework.server.netty.handler.HttpBaseHandler in project duangframework by tcrct.

the class HttpChannelInitializer method initChannel.

@Override
protected void initChannel(SocketChannel ch) throws Exception {
    ChannelPipeline p = ch.pipeline();
    if (bootStrap.isSslEnabled()) {
        sslContext = bootStrap.getSslContext();
    }
    // HttpServerCodec包含了默认的HttpRequestDecoder(请求消息解码器)和HttpResponseEncoder(响应解码器)
    p.addLast(new HttpServerCodec());
    // 为http响应内容添加gizp压缩器
    p.addLast(new HttpContentCompressor());
    // 目的是将多个消息转换为单一的request或者response对象
    p.addLast(new HttpObjectAggregator(1048576));
    // 目的是支持异步大文件传输
    p.addLast(new ChunkedWriteHandler());
    // 真正处理HTTP业务逻辑的地方,针对每个TCP连接创建一个新的ChannelHandler实例
    p.addLast(new HttpBaseHandler(bootStrap));
}
Also used : HttpObjectAggregator(io.netty.handler.codec.http.HttpObjectAggregator) ChunkedWriteHandler(io.netty.handler.stream.ChunkedWriteHandler) HttpContentCompressor(io.netty.handler.codec.http.HttpContentCompressor) HttpServerCodec(io.netty.handler.codec.http.HttpServerCodec) ChannelPipeline(io.netty.channel.ChannelPipeline) HttpBaseHandler(com.duangframework.server.netty.handler.HttpBaseHandler)

Aggregations

HttpBaseHandler (com.duangframework.server.netty.handler.HttpBaseHandler)1 ChannelPipeline (io.netty.channel.ChannelPipeline)1 HttpContentCompressor (io.netty.handler.codec.http.HttpContentCompressor)1 HttpObjectAggregator (io.netty.handler.codec.http.HttpObjectAggregator)1 HttpServerCodec (io.netty.handler.codec.http.HttpServerCodec)1 ChunkedWriteHandler (io.netty.handler.stream.ChunkedWriteHandler)1