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:com.nowopen.encrypt.web.http.HttpServerInitializer.java

License:Apache License

@Override
public void initChannel(SocketChannel ch) {
    ChannelPipeline pipeline = ch.pipeline();

    if (sslCtx != null) {
        pipeline.addLast(sslCtx.newHandler(ch.alloc()));
    }/*from   w  w  w  .  j a  va 2  s  .c om*/

    pipeline.addLast(new HttpRequestDecoder());
    pipeline.addLast(new HttpResponseEncoder());

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

    pipeline.addLast(httpIncomeRequestHandler);
}

From source file:com.tongtech.tis.fsc.TisFscServerInitializer.java

License:Apache License

@Override
public void initChannel(SocketChannel ch) {
    ChannelPipeline pipeline = ch.pipeline();

    if (sslCtx != null) {
        pipeline.addLast(sslCtx.newHandler(ch.alloc()));
    }/*from   w  ww . j a v  a2 s  . c o m*/

    //upload
    pipeline.addLast(new HttpRequestDecoder());
    pipeline.addLast(new HttpResponseEncoder());
    pipeline.addLast(new HttpObjectAggregator(65536));//outbound, HttpResponseEncoder?
    // Remove the following line if you don't want automatic content compression.
    pipeline.addLast(new HttpContentCompressor());
    pipeline.addLast(new ChunkedWriteHandler());//outbound
    pipeline.addLast(new HttpUpDownServerHandler());
}

From source file:com.topsec.bdc.platform.api.test.http.upload.HttpUploadServerInitializer.java

License:Apache License

@Override
public void initChannel(SocketChannel ch) {

    ChannelPipeline pipeline = ch.pipeline();

    if (sslCtx != null) {
        pipeline.addLast(sslCtx.newHandler(ch.alloc()));
    }//ww w .j a  v  a2 s .  com

    pipeline.addLast(new HttpRequestDecoder());
    pipeline.addLast(new HttpResponseEncoder());

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

    pipeline.addLast(new HttpUploadServerHandler());
}

From source file:debugCookies.HttpCompressorConfigurator.java

License:Apache License

@Override
public void configureNewPipeline(ChannelPipeline pipeline) {
    pipeline.addLast("deflater", new HttpContentCompressor());
}

From source file:io.crate.http.HttpTestServer.java

License:Apache License

public void run() throws InterruptedException {
    // Configure the server.
    ServerBootstrap bootstrap = new ServerBootstrap();
    group = new NioEventLoopGroup();
    bootstrap.group(group);//from   w ww . j a v  a 2s  . c o  m
    bootstrap.channel(NioServerSocketChannel.class);
    bootstrap.childHandler(new ChannelInitializer<Channel>() {

        @Override
        protected void initChannel(Channel ch) throws Exception {
            ChannelPipeline pipeline = ch.pipeline();
            pipeline.addLast("decoder", new HttpRequestDecoder());
            pipeline.addLast("encoder", new HttpResponseEncoder());
            pipeline.addLast("deflater", new HttpContentCompressor());
            pipeline.addLast("handler", new HttpTestServerHandler());
        }
    });

    // Bind and start to accept incoming connections.
    channel = bootstrap.bind(new InetSocketAddress(port)).sync().channel();
}

From source file:itlab.teleport.HttpServerInitializer.java

License:Apache License

@Override
public void initChannel(SocketChannel ch) {
    ChannelPipeline p = ch.pipeline();//from www  . j a  v  a2s.  com
    if (sslCtx != null) {
        p.addLast(sslCtx.newHandler(ch.alloc()));
    }
    p.addLast("inflater", new HttpContentDecompressor());
    p.addLast("decoder", new HttpRequestDecoder(4096, 8192, 8192, false));
    p.addLast("aggregator", new HttpObjectAggregator(1048576));
    p.addLast("encoder", new HttpResponseEncoder());
    p.addLast("deflater", new HttpContentCompressor());
    p.addLast(new HttpServerHandler());
}

From source file:malcolm.HttpProxyFrontendInitializer.java

License:Open Source License

@Override
public void initChannel(final SocketChannel ch) {
    ch.pipeline().addLast(new LoggingHandler(LogLevel.DEBUG)).addLast("decoder", new HttpRequestDecoder())
            .addLast("encoder", new HttpResponseEncoder()).addLast("deflater", new HttpContentCompressor())
            .addLast("proxy", new HttpProxyFrontendHandler());
}

From source file:net.anyflow.menton.http.WebServerChannelInitializer.java

License:Apache License

@Override
protected void initChannel(SocketChannel ch) throws Exception {
    if ("true".equalsIgnoreCase(Settings.SELF.getProperty("menton.logging.writelogOfNettyLogger"))) {
        ch.pipeline().addLast("log", new LoggingHandler("menton/server", LogLevel.DEBUG));
    }//from w  ww.  j  a  v  a2 s  .  co m

    if (useSsl) {
        SslContext sslCtx = SslContextBuilder
                .forServer(Settings.SELF.certChainFile(), Settings.SELF.privateKeyFile()).build();

        logger.debug("SSL Provider : {}", SslContext.defaultServerProvider());

        ch.pipeline().addLast(sslCtx.newHandler(ch.alloc()));
    }

    ch.pipeline().addLast(HttpServerCodec.class.getName(), new HttpServerCodec());
    ch.pipeline().addLast(HttpObjectAggregator.class.getName(), new HttpObjectAggregator(1048576));
    ch.pipeline().addLast(HttpContentCompressor.class.getName(), new HttpContentCompressor());
    ch.pipeline().addLast(HttpRequestRouter.class.getName(), new HttpRequestRouter());

    if (websocketFrameHandlerClass != null) {
        WebsocketFrameHandler wsfh = websocketFrameHandlerClass.newInstance();

        ch.pipeline().addLast(WebSocketServerProtocolHandler.class.getName(),
                new WebSocketServerProtocolHandler(wsfh.websocketPath(), wsfh.subprotocols(),
                        wsfh.allowExtensions(), wsfh.maxFrameSize()));

        ch.pipeline().addLast(wsfh);
    }
}

From source file:net.javaforge.netty.servlet.bridge.ServletBridgeChannelPipelineFactory.java

License:Apache License

protected ChannelPipeline getDefaulHttpChannelPipeline() {

    // Create a default pipeline implementation.
    ChannelPipeline pipeline = pipeline();

    pipeline.addLast("decoder", new HttpRequestDecoder());
    //        pipeline.addLast("aggregator", new HttpChunkAggregator(1048576));
    pipeline.addLast("encoder", new HttpResponseEncoder());

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

    return pipeline;
}

From source file:net.myscloud.pandora.http.server.HttpServerInitializer.java

License:Apache License

@Override
public void initChannel(SocketChannel ch) {
    // Create a default pipeline implementation.
    ChannelPipeline pipeline = ch.pipeline();

    /**/*from w  ww.ja  va2  s  . c  o m*/
     * http-request
     * httprequest
     */
    pipeline.addLast("decoder", new HttpRequestDecoder());
    /**
     * http-response
     * httpresponse
     */
    pipeline.addLast("encoder", new HttpResponseEncoder());

    /**
     * 
     * Compresses an HttpMessage and an HttpContent in gzip or deflate encoding
     * while respecting the "Accept-Encoding" header.
     * If there is no matching encoding, no compression is done.
     */
    pipeline.addLast("deflater", new HttpContentCompressor());

    pipeline.addLast(new HttpObjectAggregator(65536));

    pipeline.addLast(new ChunkedWriteHandler());

    pipeline.addLast(new HttpServerHandler());
}