List of usage examples for io.netty.handler.codec.http HttpContentCompressor HttpContentCompressor
public HttpContentCompressor()
From source file:HttpUploadServerInitializer.java
License:Apache License
@Override public void initChannel(SocketChannel ch) throws Exception { // Create a default pipeline implementation. ChannelPipeline pipeline = ch.pipeline(); if (HttpUploadServer.isSSL) { SSLEngine engine = SecureChatSslContextFactory.getServerContext().createSSLEngine(); engine.setUseClientMode(false);/*from w w w . j a v a2s . com*/ pipeline.addLast("ssl", new SslHandler(engine)); } 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("handler", new HttpUploadServerHandler()); }
From source file:com.buildria.mocking.stub.StubHttpServer.java
License:Open Source License
@Override public StubHttpServer start() { Stopwatch sw = createStarted();//from w ww.j a v a 2 s .co m bossGroup = new NioEventLoopGroup(); workerGroup = new NioEventLoopGroup(); ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .childHandler(new ChannelInitializer<SocketChannel>() { // CHECKSTYLE:OFF @Override public void initChannel(SocketChannel ch) throws Exception { // CHECKSTYLE:ON // int maxInitialLineLength, int maxHeaderSize, int maxChunkSize ch.pipeline().addLast("decoder", new HttpRequestDecoder(MAX_INITIALLINE_LENGH, MAX_HEADERS_SIZE, MAX_CHUNK_SIZE)); ch.pipeline().addLast("aggregator", new HttpObjectAggregator(MAX_CONTENT_LENGTH)); ch.pipeline().addLast("encoder", new HttpResponseEncoder()); ch.pipeline().addLast("deflater", new HttpContentCompressor()); if (config.isLogging()) { ch.pipeline().addLast("logging", new LoggingHandler(StubHttpServer.class)); } ch.pipeline().addLast("handler", new Handler()); } }).option(ChannelOption.SO_BACKLOG, SO_BACKLOG).childOption(ChannelOption.SO_KEEPALIVE, true); // Bind and start to accept incoming connections. int port = config.getPort(); ChannelFuture f; try { f = b.bind(port).sync(); } catch (InterruptedException ex) { throw new MockingException(ex); } f.awaitUninterruptibly(); sw.stop(); LOG.debug("### StubHttpServer(port:{}) started. It took {}", port, sw); return this; }
From source file:com.chiorichan.http.HttpInitializer.java
License:Mozilla Public License
@Override protected void initChannel(SocketChannel ch) throws Exception { ChannelPipeline p = ch.pipeline();//from w ww . ja v a 2s . c o m p.addLast("decoder", new HttpRequestDecoder()); p.addLast("aggregator", new HttpObjectAggregator(104857600)); // One Hundred Megabytes p.addLast("encoder", new HttpResponseEncoder()); p.addLast("deflater", new HttpContentCompressor()); p.addLast("handler", new HttpHandler(false)); activeChannels.add(new WeakReference<SocketChannel>(ch)); }
From source file:com.chiorichan.http.ssl.SslInitializer.java
License:Mozilla Public License
@Override protected void initChannel(SocketChannel ch) throws Exception { ChannelPipeline p = ch.pipeline();// w ww .j a v a 2s. c om try { p.addLast(new SniNegotiator()); } catch (Exception e) { NetworkManager.shutdownHttpsServer(); throw new IllegalStateException("The SSL engine failed to initalize", e); } p.addLast("decoder", new HttpRequestDecoder()); p.addLast("aggregator", new HttpObjectAggregator(Integer.MAX_VALUE)); p.addLast("encoder", new HttpResponseEncoder()); p.addLast("deflater", new HttpContentCompressor()); p.addLast("handler", new HttpHandler(true)); activeChannels.add(new WeakReference<SocketChannel>(ch)); }
From source file:com.chiorichan.https.HttpsInitializer.java
License:Mozilla Public License
@Override protected void initChannel(SocketChannel ch) throws Exception { ChannelPipeline p = ch.pipeline();/*from w ww. ja va2 s.co m*/ try { SSLContext context = SslContextFactory.getServerContext(); if (context == null) { NetworkManager.shutdownHttpsServer(); Loader.getLogger() .severe("The SSL engine failed to initalize, possibly due to a missing certificate file"); return; } SSLEngine engine = context.createSSLEngine(); engine.setUseClientMode(false); p.addLast("ssl", new SslHandler(engine)); } catch (Exception e) { NetworkManager.shutdownHttpsServer(); throw new IllegalStateException("The SSL engine failed to initalize", e); } p.addLast("decoder", new HttpRequestDecoder()); p.addLast("aggregator", new HttpObjectAggregator(104857600)); p.addLast("encoder", new HttpResponseEncoder()); p.addLast("deflater", new HttpContentCompressor()); p.addLast("handler", new HttpHandler(true)); }
From source file:com.cmz.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())); }/* w w w .j a va2 s . co m*/ 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:com.flysoloing.learning.network.netty.portunification.PortUnificationServerHandler.java
License:Apache License
private void switchToHttp(ChannelHandlerContext ctx) { ChannelPipeline p = ctx.pipeline();// ww w .ja va 2 s . c om p.addLast("decoder", new HttpRequestDecoder()); p.addLast("encoder", new HttpResponseEncoder()); p.addLast("deflater", new HttpContentCompressor()); p.addLast("handler", new HttpSnoopServerHandler()); p.remove(this); }
From source file:com.hop.hhxx.example.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())); }//w w w. j a v a 2s.c o m 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 io.netty.example.http.upload.HttpUploadServerHandler()); }
From source file:com.hzmsc.scada.Jmtis.server.PortUnificationServerHandler.java
License:Apache License
private void switchToHttp(ChannelHandlerContext ctx) { ChannelPipeline p = ctx.pipeline();//from www .j a va2 s. c om p.addLast("decoder", new HttpRequestDecoder()); p.addLast("encoder", new HttpResponseEncoder()); p.addLast("deflater", new HttpContentCompressor()); p.addLast("handler", new HttpHelloWorldServerHandler()); p.remove(this); }
From source file:com.netty.HttpHelloWorldServerInitializer.java
License:Apache License
@Override public void initChannel(SocketChannel ch) { ChannelPipeline p = ch.pipeline();/*from w ww .j a va 2 s.c om*/ if (sslCtx != null) { p.addLast(sslCtx.newHandler(ch.alloc())); } // p.addLast(new HttpServerCodec(4096, 8192, 8192, false)); p.addLast(new HttpServerCodec(4096, 8192, 8192, false)); p.addLast("decompressor", new HttpContentDecompressor()); p.addLast("aggegator", new HttpObjectAggregator(512 * 1024)); // p.addLast(new HttpAggregatorInitializer(false)); ServerBaseHandler channelHandler = applicationContext.getBean(ServerBaseHandler.class); channelHandler.setApplicationContext(applicationContext); // p.addLast(new HttpHelloWorldServerHandler()); p.addLast(channelHandler); p.addLast(new HttpContentCompressor()); }