本文整理匯總了Java中io.netty.handler.codec.http.HttpContentDecompressor類的典型用法代碼示例。如果您正苦於以下問題:Java HttpContentDecompressor類的具體用法?Java HttpContentDecompressor怎麽用?Java HttpContentDecompressor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
HttpContentDecompressor類屬於io.netty.handler.codec.http包,在下文中一共展示了HttpContentDecompressor類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initChannel
import io.netty.handler.codec.http.HttpContentDecompressor; //導入依賴的package包/類
/**
* Adds pipelines to channel.
*
* @param ch channel to be operated on
*/
protected void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline pipe = ch.pipeline();
if (ssl) {
// HTTPs connection
SSLEngine sslEng = getSsl(null);
sslEng.setUseClientMode(true);
pipe.addLast("SSL", new SslHandler(sslEng, false));
}
pipe.addFirst("Timer", new ReadTimeoutHandler(30));
pipe.addLast("Codec", new HttpClientCodec());
pipe.addLast("Inflater", new HttpContentDecompressor());
pipe.addLast("Handler", new HTTPMessageHandler(builder));
}
示例2: initChannel
import io.netty.handler.codec.http.HttpContentDecompressor; //導入依賴的package包/類
@Override
public void initChannel(SocketChannel ch) throws Exception {
// Create a default pipeline implementation.
ChannelPipeline p = ch.pipeline();
p.addLast("log", new LoggingHandler(LogLevel.INFO));
// Enable HTTPS if necessary.
/* if (ssl) {
SSLEngine engine =
SecureChatSslContextFactory.getClientContext().createSSLEngine();
engine.setUseClientMode(true);
p.addLast("ssl", new SslHandler(engine));
}*/
p.addLast("codec", new HttpClientCodec());
// Remove the following line if you don't want automatic content decompression.
p.addLast("inflater", new HttpContentDecompressor());
// Uncomment the following line if you don't want to handle HttpChunks.
//p.addLast("aggregator", new HttpObjectAggregator(1048576));
p.addLast("handler", new HttpSnoopClientHandler());
}
示例3: initChannel
import io.netty.handler.codec.http.HttpContentDecompressor; //導入依賴的package包/類
@Override
public void initChannel(SocketChannel ch) {
ChannelPipeline pipeline = ch.pipeline();
if (sslCtx != null) {
pipeline.addLast("ssl", sslCtx.newHandler(ch.alloc()));
}
pipeline.addLast("codec", new HttpClientCodec());
// Remove the following line if you don't want automatic content decompression.
pipeline.addLast("inflater", new HttpContentDecompressor());
// to be used since huge file transfer
pipeline.addLast("chunkedWriter", new ChunkedWriteHandler());
pipeline.addLast("handler", new HttpUploadClientHandler());
}
示例4: initChannel
import io.netty.handler.codec.http.HttpContentDecompressor; //導入依賴的package包/類
@Override
public void initChannel(SocketChannel ch) {
ChannelPipeline p = ch.pipeline();
// Enable HTTPS if necessary.
if (sslCtx != null) {
p.addLast(sslCtx.newHandler(ch.alloc()));
}
p.addLast(new HttpClientCodec());
// Remove the following line if you don't want automatic content decompression.
p.addLast(new HttpContentDecompressor());
// Uncomment the following line if you don't want to handle HttpContents.
//p.addLast(new HttpObjectAggregator(1048576));
p.addLast(new HttpSnoopClientHandler());
}
示例5: initChannel
import io.netty.handler.codec.http.HttpContentDecompressor; //導入依賴的package包/類
@Override
public void initChannel(SocketChannel ch) {
ChannelPipeline pipeline = ch.pipeline();
// Enable HTTPS if necessary.
// if (sslCtx != null) {
// pipeline.addLast(sslCtx.newHandler(ch.alloc()));
// }
pipeline.addLast(new HttpClientCodec());
// Remove the following line if you don't want automatic content decompression.
pipeline.addLast(new HttpContentDecompressor());
// Uncomment the following line if you don't want to handle HttpContents.
//pipeline.addLast(new HttpObjectAggregator(65536));
pipeline.addLast(new HttpObjectAggregator(65536 * 3));
// pipeline.addLast(new HttpClientHandler(null, mHttpClientListener));
}
示例6: configNewChannel
import io.netty.handler.codec.http.HttpContentDecompressor; //導入依賴的package包/類
@Override
public void configNewChannel(NioSocketChannel channel) {
super.configNewChannel(channel);
ChannelPipeline pipeline = channel.pipeline();
// 添加 SSL 數據支持
if (requestConfig.https()) {
SslContext sslContent = NettyCenter.singleInstance().getSimpleClientSslContext();
SSLEngine engine = sslContent.newEngine(channel.alloc());
pipeline.addLast("ssl", new SslHandler(engine));
}
// 客戶端接收到的是httpResponse響應,所以要使用HttpResponseDecoder進行解碼
pipeline.addLast("decoder", new HttpResponseDecoder());
// 客戶端發送的是httprequest,所以要使用HttpRequestEncoder進行編碼
pipeline.addLast("encoder", new HttpRequestEncoder());
// 接收的請求累計器
pipeline.addLast("aggegator", new HttpObjectAggregator(0x30000));
// mime 類型寫出
pipeline.addLast("streamew", new ChunkedWriteHandler());
// 添加解壓器
pipeline.addLast("decompressor", new HttpContentDecompressor());
// add new handler
pipeline.addLast("handler", new NettyHttpRequestChannelHandler());
}
示例7: initChannel
import io.netty.handler.codec.http.HttpContentDecompressor; //導入依賴的package包/類
@Override
protected void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline();
//inbound handler
pipeline.addLast(new HttpRequestDecoder());
pipeline.addLast(new HttpContentDecompressor());
//outbound handler
pipeline.addLast(new HttpResponseEncoder());
pipeline.addLast(new HttpContentCompressor());
//pipeline.addLast(new ChunkedWriteHandler());
pipeline.addLast(new HttpObjectAggregator(this.sc.getSize()));
pipeline.addLast(this.galeHttpHandler);
}
示例8: initChannel
import io.netty.handler.codec.http.HttpContentDecompressor; //導入依賴的package包/類
@Override
public void initChannel(SocketChannel ch) {
ChannelPipeline p = ch.pipeline();
// Enable HTTPS if necessary.
if (sslCtx != null) {
p.addLast(sslCtx.newHandler(ch.alloc()));
}
p.addLast(new HttpClientCodec());
// Remove the following line if you don't want automatic content decompression.
p.addLast(new HttpContentDecompressor());
// Uncomment the following line if you don't want to handle HttpContents.
//p.addLast(new HttpObjectAggregator(1048576));
p.addLast(handler);
}
示例9: initChannel
import io.netty.handler.codec.http.HttpContentDecompressor; //導入依賴的package包/類
@Override
public void initChannel(SocketChannel ch) throws Exception {
// Create a default pipeline implementation.
ChannelPipeline pipeline = ch.pipeline();
if (ssl) {
SSLEngine engine = SecureChatSslContextFactory.getClientContext().createSSLEngine();
engine.setUseClientMode(true);
pipeline.addLast("ssl", new SslHandler(engine));
}
pipeline.addLast("codec", new HttpClientCodec());
// Remove the following line if you don't want automatic content decompression.
pipeline.addLast("inflater", new HttpContentDecompressor());
// to be used since huge file transfer
pipeline.addLast("chunkedWriter", new ChunkedWriteHandler());
pipeline.addLast("handler", new HttpUploadClientHandler());
}
示例10: initChannel
import io.netty.handler.codec.http.HttpContentDecompressor; //導入依賴的package包/類
@Override
public void initChannel(SocketChannel ch) throws Exception {
// Create a default pipeline implementation.
ChannelPipeline p = ch.pipeline();
p.addLast("log", new LoggingHandler(LogLevel.INFO));
// Enable HTTPS if necessary.
if (ssl) {
SSLEngine engine =
SecureChatSslContextFactory.getClientContext().createSSLEngine();
engine.setUseClientMode(true);
p.addLast("ssl", new SslHandler(engine));
}
p.addLast("codec", new HttpClientCodec());
// Remove the following line if you don't want automatic content decompression.
p.addLast("inflater", new HttpContentDecompressor());
// Uncomment the following line if you don't want to handle HttpChunks.
//p.addLast("aggregator", new HttpObjectAggregator(1048576));
p.addLast("handler", new HttpSnoopClientHandler());
}
示例11: initChannel
import io.netty.handler.codec.http.HttpContentDecompressor; //導入依賴的package包/類
@Override
public void initChannel(SocketChannel ch) {
ChannelPipeline p = ch.pipeline();
// Enable HTTPS if necessary.
if (sslCtx != null) {
p.addLast(sslCtx.newHandler(ch.alloc()));
}
p.addLast(new HttpClientCodec());
// Remove the following line if you don't want automatic content decompression.
p.addLast(new HttpContentDecompressor());
// Uncomment the following line if you don't want to handle HttpContents.
p.addLast(new HttpObjectAggregator(1048576));
p.addLast(nettyHttpClientHandler);
}
示例12: initChannel
import io.netty.handler.codec.http.HttpContentDecompressor; //導入依賴的package包/類
@Override
public void initChannel(SocketChannel ch) {
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast("http-request-decoder", new HttpRequestDecoder());
pipeline.addLast("deflater", new HttpContentDecompressor());
pipeline.addLast("http-object-aggregator", new HttpObjectAggregator(1048576));
pipeline.addLast("http-response-encoder", new HttpResponseEncoder());
pipeline.addLast("inflater", new HttpContentCompressor());
// Alters the pipeline depending on either REST or WebSockets requests
pipeline.addLast("api-protocol-switcher", apiProtocolSwitcher);
pipeline.addLast("debugger", debugger);
// Logging handlers for API requests
pipeline.addLast("api-request-logger", apiRequestLogger);
// pipeline.addLast(rxJavaGroup, "rxjava-handler", rxjavaHandler);
// JAX-RS handlers
pipeline.addLast(jaxRsGroup, "jax-rs-handler", jaxRsHandlers);
}
示例13: switchToHttp
import io.netty.handler.codec.http.HttpContentDecompressor; //導入依賴的package包/類
private void switchToHttp(ChannelHandlerContext ctx, ByteBuf msg) {
ChannelPipeline pipeline = ctx.pipeline();
addLastIfNotPresent(pipeline, new HttpServerCodec(8192, 8192, 8192));
addLastIfNotPresent(pipeline, new HttpContentDecompressor());
addLastIfNotPresent(pipeline, httpContentLengthRemover);
addLastIfNotPresent(pipeline, new HttpObjectAggregator(Integer.MAX_VALUE));
if (mockServerLogger.isEnabled(TRACE)) {
addLastIfNotPresent(pipeline, loggingHandler);
}
configurePipeline(ctx, pipeline);
pipeline.remove(this);
ctx.channel().attr(LOCAL_HOST_HEADERS).set(getLocalAddresses(ctx));
// fire message back through pipeline
ctx.fireChannelRead(msg);
}
示例14: prepare
import io.netty.handler.codec.http.HttpContentDecompressor; //導入依賴的package包/類
@Override public void prepare(final Benchmark benchmark) {
this.concurrencyLevel = benchmark.concurrencyLevel;
this.targetBacklog = benchmark.targetBacklog;
ChannelInitializer<SocketChannel> channelInitializer = new ChannelInitializer<SocketChannel>() {
@Override public void initChannel(SocketChannel channel) throws Exception {
ChannelPipeline pipeline = channel.pipeline();
if (benchmark.tls) {
SslClient sslClient = SslClient.localhost();
SSLEngine engine = sslClient.sslContext.createSSLEngine();
engine.setUseClientMode(true);
pipeline.addLast("ssl", new SslHandler(engine));
}
pipeline.addLast("codec", new HttpClientCodec());
pipeline.addLast("inflater", new HttpContentDecompressor());
pipeline.addLast("handler", new HttpChannel(channel));
}
};
bootstrap = new Bootstrap();
bootstrap.group(new NioEventLoopGroup(concurrencyLevel))
.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
.channel(NioSocketChannel.class)
.handler(channelInitializer);
}
示例15: initChannel
import io.netty.handler.codec.http.HttpContentDecompressor; //導入依賴的package包/類
@Override
protected void initChannel(Channel ch) throws Exception {
ch.pipeline().addLast("openChannels", transport.serverOpenChannels);
final HttpRequestDecoder decoder = new HttpRequestDecoder(
Math.toIntExact(transport.maxInitialLineLength.getBytes()),
Math.toIntExact(transport.maxHeaderSize.getBytes()),
Math.toIntExact(transport.maxChunkSize.getBytes()));
decoder.setCumulator(ByteToMessageDecoder.COMPOSITE_CUMULATOR);
ch.pipeline().addLast("decoder", decoder);
ch.pipeline().addLast("decoder_compress", new HttpContentDecompressor());
ch.pipeline().addLast("encoder", new HttpResponseEncoder());
final HttpObjectAggregator aggregator = new HttpObjectAggregator(Math.toIntExact(transport.maxContentLength.getBytes()));
if (transport.maxCompositeBufferComponents != -1) {
aggregator.setMaxCumulationBufferComponents(transport.maxCompositeBufferComponents);
}
ch.pipeline().addLast("aggregator", aggregator);
if (transport.compression) {
ch.pipeline().addLast("encoder_compress", new HttpContentCompressor(transport.compressionLevel));
}
if (SETTING_CORS_ENABLED.get(transport.settings())) {
ch.pipeline().addLast("cors", new Netty4CorsHandler(transport.getCorsConfig()));
}
if (transport.pipelining) {
ch.pipeline().addLast("pipelining", new HttpPipeliningHandler(transport.pipeliningMaxEvents));
}
ch.pipeline().addLast("handler", requestHandler);
}