Example usage for io.netty.handler.codec.http HttpContentCompressor HttpContentCompressor

List of usage examples for io.netty.handler.codec.http HttpContentCompressor HttpContentCompressor

Introduction

In this page you can find the example usage for io.netty.handler.codec.http HttpContentCompressor HttpContentCompressor.

Prototype

public HttpContentCompressor() 

Source Link

Document

Creates a new handler with the default compression level (6), default window size (15) and default memory level (8).

Usage

From source file:org.wso2.carbon.transport.http.netty.listener.http2.HTTPProtocolNegotiationHandler.java

License:Open Source License

@Override
/**/*from   w w w.  j a v  a 2s .  com*/
 *  Configure pipeline after SSL handshake
 */
protected void configurePipeline(ChannelHandlerContext ctx, String protocol) throws Exception {
    ChannelPipeline p = ctx.pipeline();
    // handles pipeline for HTTP/2 requests after SSL handshake
    if (ApplicationProtocolNames.HTTP_2.equals(protocol)) {
        ctx.pipeline().addLast("http2-handler",
                new HTTP2SourceHandlerBuilder(connectionManager, listenerConfiguration).build());
        return;
    }
    // handles pipeline for HTTP/1 requests after SSL handshake
    if (ApplicationProtocolNames.HTTP_1_1.equals(protocol)) {
        p.addLast("encoder", new HttpResponseEncoder());
        if (requestSizeValidationConfig.isHeaderSizeValidation()) {
            p.addLast("decoder", new CustomHttpRequestDecoder(requestSizeValidationConfig));
        } else {
            p.addLast("decoder", new HttpRequestDecoder());
        }
        if (requestSizeValidationConfig.isRequestSizeValidation()) {
            p.addLast("custom-aggregator", new CustomHttpObjectAggregator(requestSizeValidationConfig));
        }
        p.addLast("compressor", new HttpContentCompressor());
        p.addLast("chunkWriter", new ChunkedWriteHandler());
        try {
            // TODO: Properly fix this part once we start HTTP2 integration
            p.addLast("handler", new SourceHandler(new HttpWsServerConnectorFuture(null), null));
        } catch (Exception e) {
            log.error("Cannot Create SourceHandler ", e);
        }
        return;
    }

    throw new IllegalStateException("unknown protocol: " + protocol);
}

From source file:org.wso2.carbon.transport.http.netty.sender.NettyClientInitializer.java

License:Open Source License

@Override
protected void initChannel(SocketChannel ch) throws Exception {
    // Add the generic handlers to the pipeline
    // e.g. SSL handler
    if (senderConfiguration.getSslConfig() != null) {
        log.debug("adding ssl handler");
        SslHandler sslHandler = new SSLHandlerFactory(senderConfiguration.getSslConfig()).create();
        sslHandler.engine().setUseClientMode(true);
        ch.pipeline().addLast("ssl", sslHandler);
    }//w  ww .  ja v  a  2 s.  c  om
    ch.pipeline().addLast("compressor", new HttpContentCompressor());
    ch.pipeline().addLast("decoder", new HttpResponseDecoder());
    ch.pipeline().addLast("encoder", new HttpRequestEncoder());
    ch.pipeline().addLast("chunkWriter", new ChunkedWriteHandler());

    if (senderConfiguration.isDisruptorOn()) {
        log.debug("Register target handler in pipeline which will dispatch events to Disruptor threads");
        handler = new TargetHandler(soTimeOut);
        ch.pipeline().addLast(HANDLER, handler);
    } else {
        log.debug("Register  engine dispatching handler in pipeline ");
        handler = new WorkerPoolDispatchingTargetHandler(soTimeOut, senderConfiguration);
        ch.pipeline().addLast(HANDLER, handler);
    }

}

From source file:org.wso2.carbon.transport.http.netty.sender.RedirectChannelInitializer.java

License:Open Source License

@Override
protected void initChannel(SocketChannel ch) throws Exception {
    // Add the generic handlers to the pipeline
    // e.g. SSL handler
    if (sslEngine != null) {
        if (log.isDebugEnabled()) {
            log.debug("adding ssl handler");
        }// w  w w  .  ja v  a2 s .  c  o  m
        ch.pipeline().addLast("ssl", new SslHandler(this.sslEngine));
    }
    ch.pipeline().addLast("compressor", new HttpContentCompressor());
    ch.pipeline().addLast("decoder", new HttpResponseDecoder());
    ch.pipeline().addLast("encoder", new HttpRequestEncoder());
    if (httpTraceLogEnabled) {
        ch.pipeline().addLast(Constants.HTTP_TRACE_LOG_HANDLER,
                new HTTPTraceLoggingHandler("tracelog.http.upstream", LogLevel.DEBUG));
    }
    RedirectHandler redirectHandler = new RedirectHandler(sslEngine, httpTraceLogEnabled, maxRedirectCount,
            chunkDisabled, originalChannelContext, isIdleHandlerOfTargetChannelRemoved);
    ch.pipeline().addLast(Constants.REDIRECT_HANDLER, redirectHandler);
}

From source file:org.wso2.msf4j.internal.MSF4JNettyServerInitializer.java

License:Open Source License

public void initChannel(SocketChannel channel) {
    ChannelPipeline pipeline = channel.pipeline();
    pipeline.addLast("decoder", new HttpRequestDecoder());
    pipeline.addLast("encoder", new HttpResponseEncoder());
    pipeline.addLast("compressor", new HttpContentCompressor());
    pipeline.addLast("streamer", new ChunkedWriteHandler());
    pipeline.addLast("router", new RequestRouter(microservicesRegistry.getHttpResourceHandler(), 0));
    pipeline.addLast(eventExecutorGroup, "dispatcher", new HttpDispatcher());
}