org.jboss.netty.handler.codec.http.HttpContentCompressor Java Examples

The following examples show how to use org.jboss.netty.handler.codec.http.HttpContentCompressor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FileServerPipelineFactory.java    From netty-file-parent with Apache License 2.0 6 votes vote down vote up
public ChannelPipeline getPipeline() throws Exception {
	ChannelPipeline pipeline = Channels.pipeline();
	//它负责把字节解码成Http请求。
	pipeline.addLast("decoder", new HttpRequestDecoder());
	//当Server处理完消息后,需要向Client发送响应。那么需要把响应编码成字节,再发送出去。故添加HttpResponseEncoder处理器。
	pipeline.addLast("encoder", new HttpResponseEncoder());
	//它负责把多个HttpMessage组装成一个完整的Http请求或者响应。到底是组装成请求还是响应,则取决于它所处理的内容是请求的内容,还是响应的内容。
	//这其实可以通过Inbound和Outbound来判断,对于Server端而言,在Inbound 端接收请求,在Outbound端返回响应。
	//如果Server向Client返回的数据指定的传输编码是 chunked。则,Server不需要知道发送给Client的数据总长度是多少,它是通过分块发送的,参考分块传输编码
	//pipeline.addLast("http-aggregator", new HttpObjectAggregator(65536));
	pipeline.addLast("deflater", new HttpContentCompressor());
	//该通道处理器主要是为了处理大文件传输的情形。大文件传输时,需要复杂的状态管理,而ChunkedWriteHandler实现这个功能。
	pipeline.addLast("http-chunked", new ChunkedWriteHandler());
	//自定义的通道处理器,其目的是实现文件服务器的业务逻辑。
	pipeline.addLast("handler", new FileServerHandler());
	return pipeline;
}
 
Example #2
Source File: HttpDataServerPipelineFactory.java    From incubator-tajo with Apache License 2.0 6 votes vote down vote up
public ChannelPipeline getPipeline() throws Exception {
  // Create a default pipeline implementation.
  ChannelPipeline pipeline = pipeline();

  // Uncomment the following line if you want HTTPS
  // SSLEngine engine =
  // SecureChatSslContextFactory.getServerContext().createSSLEngine();
  // engine.setUseClientMode(false);
  // pipeline.addLast("ssl", new SslHandler(engine));

  pipeline.addLast("decoder", new HttpRequestDecoder());
  //pipeline.addLast("aggregator", new HttpChunkAggregator(65536));
  pipeline.addLast("encoder", new HttpResponseEncoder());
  pipeline.addLast("chunkedWriter", new ChunkedWriteHandler());
  pipeline.addLast("deflater", new HttpContentCompressor());
  pipeline.addLast("handler", new HttpDataServerHandler(userName, appId));
  return pipeline;
}
 
Example #3
Source File: HttpOutboundPipeline.java    From zuul-netty with Apache License 2.0 6 votes vote down vote up
@Override
public ChannelPipeline getPipeline() throws Exception {
    ChannelPipeline pipeline = pipeline();

    pipeline.addLast("idle-detection", IDLE_STATE_HANDLER);
    pipeline.addLast("logging", new LoggingHandler(InternalLogLevel.DEBUG));
    pipeline.addLast("http-deflater", new HttpContentCompressor());
    pipeline.addLast("decoder", new HttpResponseDecoder(RESPONSE_MAX_INITIAL_LINE_LENGTH, RESPONSE_MAX_HEADER_SIZE, RESPONSE_MAX_CHUNK_SIZE));
    pipeline.addLast("encoder", new HttpRequestEncoder());
    pipeline.addLast("http-inflater", new HttpContentDecompressor());
    pipeline.addLast("remote-hop-timer", new ClientTimingHandler("outbound"));
    pipeline.addLast("exception-surfacer", EXCEPTION_SURFACER);
    pipeline.addLast("idle-watchdog", new IdleChannelWatchdog("outbound"));

    return pipeline;
}
 
Example #4
Source File: NettyHttpServerTransport.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public ChannelPipeline getPipeline() throws Exception {
    ChannelPipeline pipeline = Channels.pipeline();
    pipeline.addLast("openChannels", transport.serverOpenChannels);
    HttpRequestDecoder requestDecoder = new HttpRequestDecoder(
            (int) transport.maxInitialLineLength.bytes(),
            (int) transport.maxHeaderSize.bytes(),
            (int) transport.maxChunkSize.bytes()
    );
    if (transport.maxCumulationBufferCapacity != null) {
        if (transport.maxCumulationBufferCapacity.bytes() > Integer.MAX_VALUE) {
            requestDecoder.setMaxCumulationBufferCapacity(Integer.MAX_VALUE);
        } else {
            requestDecoder.setMaxCumulationBufferCapacity((int) transport.maxCumulationBufferCapacity.bytes());
        }
    }
    if (transport.maxCompositeBufferComponents != -1) {
        requestDecoder.setMaxCumulationBufferComponents(transport.maxCompositeBufferComponents);
    }
    pipeline.addLast("decoder", requestDecoder);
    pipeline.addLast("decoder_compress", new ESHttpContentDecompressor(transport.compression));
    HttpChunkAggregator httpChunkAggregator = new HttpChunkAggregator((int) transport.maxContentLength.bytes());
    if (transport.maxCompositeBufferComponents != -1) {
        httpChunkAggregator.setMaxCumulationBufferComponents(transport.maxCompositeBufferComponents);
    }
    pipeline.addLast("aggregator", httpChunkAggregator);
    pipeline.addLast("encoder", new ESHttpResponseEncoder());
    if (transport.compression) {
        pipeline.addLast("encoder_compress", new HttpContentCompressor(transport.compressionLevel));
    }
    if (transport.settings().getAsBoolean(SETTING_CORS_ENABLED, false)) {
        pipeline.addLast("cors", new CorsHandler(transport.getCorsConfig()));
    }
    if (transport.pipelining) {
        pipeline.addLast("pipelining", new HttpPipeliningHandler(transport.pipeliningMaxEvents));
    }
    pipeline.addLast("handler", requestHandler);
    return pipeline;
}
 
Example #5
Source File: HttpServer.java    From glowroot with Apache License 2.0 5 votes vote down vote up
@Override
public ChannelPipeline getPipeline() throws Exception {
    ChannelPipeline pipeline = Channels.pipeline();
    pipeline.addLast("decoder", new HttpRequestDecoder());
    pipeline.addLast("encoder", new HttpResponseEncoder());
    pipeline.addLast("deflater", new HttpContentCompressor());
    pipeline.addLast("handler", new HttpServerHandler());
    return pipeline;
}
 
Example #6
Source File: CommonHttpPipeline.java    From zuul-netty with Apache License 2.0 5 votes vote down vote up
@Override
public ChannelPipeline getPipeline() throws Exception {
    ChannelPipeline pipeline = Channels.pipeline();

    //offload from worker threads
    pipeline.addLast("app-execution-handler", APP_EXECUTION_HANDLER);

    //httpfu io
    pipeline.addLast("socket-suspension", new SocketSuspensionHandler());
    pipeline.addLast("idle-detection", idleStateHandler);
    pipeline.addLast("http-decoder", new HttpRequestDecoder());
    pipeline.addLast("http-encoder", new HttpResponseEncoder());

    //httpfu
    pipeline.addLast("http-deflater", new HttpContentCompressor());
    pipeline.addLast("edge-timer", SERVER_TIMING_HANDLER);
    pipeline.addLast("http-keep-alive", KEEP_ALIVE_HANDLER);
    pipeline.addLast("idle-watchdog", IDLE_CHANNEL_WATCHDOG_HANDLER);

    //response handlers
    addZuulPostFilters(pipeline, postFilters);

    pipeline.addLast("app-http-response-logger", HTTP_RESPONSE_LOGGER);

    //request handlers
    addZuulPreFilters(pipeline, preFilters);

    //proxy
    pipeline.addLast("proxy", new HttpProxyHandler(outboundConnectionPool, IS_REQUEST_CHUNKED_ENABLED));

    return pipeline;
}
 
Example #7
Source File: HttpServerPipelineFactory.java    From netty-servlet with Apache License 2.0 4 votes vote down vote up
public ChannelPipeline getPipeline() throws Exception {
    // Create a default pipeline implementation.
    ChannelPipeline pipeline = pipeline();

    pipeline.addLast("decoder", new HttpRequestDecoder());

    pipeline.addLast("encoder", new HttpResponseEncoder());

    // Remove the following line if you don't want automatic content compression.
    pipeline.addLast("deflater", new HttpContentCompressor());

    pipeline.addLast("excution", executionHandler);

    pipeline.addLast("handler", new HttpServerHandler(dispatcher));
    return pipeline;
}