Search in sources :

Example 1 with HttpResponseEncoder

use of io.netty.handler.codec.http.HttpResponseEncoder in project asterixdb by apache.

the class HttpServerInitializer method initChannel.

@Override
public void initChannel(SocketChannel ch) {
    ChannelPipeline p = ch.pipeline();
    p.addLast(new HttpRequestDecoder(MAX_REQUEST_INITIAL_LINE_LENGTH, MAX_REQUEST_HEADER_SIZE, MAX_REQUEST_CHUNK_SIZE));
    p.addLast(new HttpResponseEncoder());
    p.addLast(new HttpObjectAggregator(Integer.MAX_VALUE));
    p.addLast(server.createHttpHandler(RESPONSE_CHUNK_SIZE));
}
Also used : HttpResponseEncoder(io.netty.handler.codec.http.HttpResponseEncoder) HttpObjectAggregator(io.netty.handler.codec.http.HttpObjectAggregator) HttpRequestDecoder(io.netty.handler.codec.http.HttpRequestDecoder) ChannelPipeline(io.netty.channel.ChannelPipeline)

Example 2 with HttpResponseEncoder

use of io.netty.handler.codec.http.HttpResponseEncoder in project camel by apache.

the class HttpServerSharedInitializerFactory method initChannel.

@Override
protected void initChannel(Channel ch) throws Exception {
    // create a new pipeline
    ChannelPipeline pipeline = ch.pipeline();
    SslHandler sslHandler = configureServerSSLOnDemand();
    if (sslHandler != null) {
        LOG.debug("Server SSL handler configured and added as an interceptor against the ChannelPipeline: {}", sslHandler);
        pipeline.addLast("ssl", sslHandler);
    }
    pipeline.addLast("decoder", new HttpRequestDecoder(409, configuration.getMaxHeaderSize(), 8192));
    pipeline.addLast("encoder", new HttpResponseEncoder());
    if (configuration.isChunked()) {
        pipeline.addLast("aggregator", new HttpObjectAggregator(configuration.getChunkedMaxContentLength()));
    }
    if (configuration.isCompression()) {
        pipeline.addLast("deflater", new HttpContentCompressor());
    }
    pipeline.addLast("handler", channelFactory.getChannelHandler());
}
Also used : HttpResponseEncoder(io.netty.handler.codec.http.HttpResponseEncoder) HttpObjectAggregator(io.netty.handler.codec.http.HttpObjectAggregator) HttpRequestDecoder(io.netty.handler.codec.http.HttpRequestDecoder) HttpContentCompressor(io.netty.handler.codec.http.HttpContentCompressor) ChannelPipeline(io.netty.channel.ChannelPipeline) SslHandler(io.netty.handler.ssl.SslHandler)

Example 3 with HttpResponseEncoder

use of io.netty.handler.codec.http.HttpResponseEncoder in project pancm_project by xuwujing.

the class NettyServerFilter method initChannel.

@Override
protected void initChannel(SocketChannel ch) throws Exception {
    ChannelPipeline ph = ch.pipeline();
    // 处理http服务的关键handler
    ph.addLast("encoder", new HttpResponseEncoder());
    ph.addLast("decoder", new HttpRequestDecoder());
    ph.addLast("aggregator", new HttpObjectAggregator(10 * 1024 * 1024));
    // 服务端业务逻辑
    ph.addLast("handler", new NettyServerHandler());
}
Also used : HttpResponseEncoder(io.netty.handler.codec.http.HttpResponseEncoder) HttpObjectAggregator(io.netty.handler.codec.http.HttpObjectAggregator) HttpRequestDecoder(io.netty.handler.codec.http.HttpRequestDecoder) ChannelPipeline(io.netty.channel.ChannelPipeline)

Example 4 with HttpResponseEncoder

use of io.netty.handler.codec.http.HttpResponseEncoder in project tesla by linking12.

the class ClientToProxyConnection method initChannelPipeline.

private void initChannelPipeline(ChannelPipeline pipeline) {
    LOG.debug("Configuring ChannelPipeline");
    pipeline.addLast("bytesReadMonitor", bytesReadMonitor);
    pipeline.addLast("bytesWrittenMonitor", bytesWrittenMonitor);
    pipeline.addLast("encoder", new HttpResponseEncoder());
    pipeline.addLast("decoder", new HttpRequestDecoder(proxyServer.getMaxInitialLineLength(), proxyServer.getMaxHeaderSize(), proxyServer.getMaxChunkSize()));
    int numberOfBytesToBuffer = proxyServer.getFiltersSource().getMaximumRequestBufferSizeInBytes();
    if (numberOfBytesToBuffer > 0) {
        aggregateContentForFiltering(pipeline, numberOfBytesToBuffer);
    }
    pipeline.addLast("requestReadMonitor", requestReadMonitor);
    pipeline.addLast("responseWrittenMonitor", responseWrittenMonitor);
    pipeline.addLast("idle", new IdleStateHandler(0, 0, proxyServer.getIdleConnectionTimeout()));
    pipeline.addLast("handler", this);
}
Also used : HttpResponseEncoder(io.netty.handler.codec.http.HttpResponseEncoder) HttpRequestDecoder(io.netty.handler.codec.http.HttpRequestDecoder) IdleStateHandler(io.netty.handler.timeout.IdleStateHandler)

Example 5 with HttpResponseEncoder

use of io.netty.handler.codec.http.HttpResponseEncoder in project cxf by apache.

the class NettyHttpServletPipelineFactory method getDefaulHttpChannelPipeline.

protected ChannelPipeline getDefaulHttpChannelPipeline(Channel channel) throws Exception {
    // Create a default pipeline implementation.
    ChannelPipeline pipeline = channel.pipeline();
    SslHandler sslHandler = configureServerSSLOnDemand();
    if (sslHandler != null) {
        LOG.log(Level.FINE, "Server SSL handler configured and added as an interceptor against the ChannelPipeline: {}", sslHandler);
        pipeline.addLast("ssl", sslHandler);
    }
    pipeline.addLast("decoder", new HttpRequestDecoder());
    pipeline.addLast("encoder", new HttpResponseEncoder());
    pipeline.addLast("aggregator", new HttpObjectAggregator(maxChunkContentSize));
    // Remove the following line if you don't want automatic content
    // compression.
    pipeline.addLast("deflater", new HttpContentCompressor());
    // Set up the idle handler
    pipeline.addLast("idle", new IdleStateHandler(nettyHttpServerEngine.getReadIdleTime(), nettyHttpServerEngine.getWriteIdleTime(), 0));
    return pipeline;
}
Also used : HttpResponseEncoder(io.netty.handler.codec.http.HttpResponseEncoder) HttpObjectAggregator(io.netty.handler.codec.http.HttpObjectAggregator) HttpRequestDecoder(io.netty.handler.codec.http.HttpRequestDecoder) HttpContentCompressor(io.netty.handler.codec.http.HttpContentCompressor) IdleStateHandler(io.netty.handler.timeout.IdleStateHandler) ChannelPipeline(io.netty.channel.ChannelPipeline) SslHandler(io.netty.handler.ssl.SslHandler)

Aggregations

HttpResponseEncoder (io.netty.handler.codec.http.HttpResponseEncoder)49 HttpRequestDecoder (io.netty.handler.codec.http.HttpRequestDecoder)44 HttpObjectAggregator (io.netty.handler.codec.http.HttpObjectAggregator)28 ChannelPipeline (io.netty.channel.ChannelPipeline)24 ServerBootstrap (io.netty.bootstrap.ServerBootstrap)12 HttpContentCompressor (io.netty.handler.codec.http.HttpContentCompressor)11 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)10 NioServerSocketChannel (io.netty.channel.socket.nio.NioServerSocketChannel)10 ChunkedWriteHandler (io.netty.handler.stream.ChunkedWriteHandler)10 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)9 SocketChannel (io.netty.channel.socket.SocketChannel)9 EventLoopGroup (io.netty.channel.EventLoopGroup)7 SslHandler (io.netty.handler.ssl.SslHandler)7 Channel (io.netty.channel.Channel)6 DefaultFullHttpResponse (io.netty.handler.codec.http.DefaultFullHttpResponse)6 LoggingHandler (io.netty.handler.logging.LoggingHandler)6 Test (org.junit.jupiter.api.Test)6 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)5 FullHttpResponse (io.netty.handler.codec.http.FullHttpResponse)5 InetSocketAddress (java.net.InetSocketAddress)5