/**
* 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));
}
java类io.netty.handler.codec.http.HttpContentDecompressor的实例源码
HTTPInitializer.java 文件源码
项目:onedatashare
阅读 30
收藏 0
点赞 0
评论 0
HTTPInitializer.java 文件源码
项目:Stork
阅读 23
收藏 0
点赞 0
评论 0
/**
* 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));
}
HttpSnoopClientInitializer.java 文件源码
项目:ServiceCOLDCache
阅读 18
收藏 0
点赞 0
评论 0
@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());
}
HttpUploadClientIntializer.java 文件源码
项目:JavaAyo
阅读 20
收藏 0
点赞 0
评论 0
@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());
}
HttpSnoopClientInitializer.java 文件源码
项目:JavaAyo
阅读 30
收藏 0
点赞 0
评论 0
@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());
}
HttpClientInitializer.java 文件源码
项目:SI
阅读 28
收藏 0
点赞 0
评论 0
@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));
}
NHttpRequest.java 文件源码
项目:GameServerFramework
阅读 21
收藏 0
点赞 0
评论 0
@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());
}
HttpUploadClientIntializer.java 文件源码
项目:netty4.0.27Learn
阅读 20
收藏 0
点赞 0
评论 0
@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());
}
HttpSnoopClientInitializer.java 文件源码
项目:netty4.0.27Learn
阅读 20
收藏 0
点赞 0
评论 0
@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());
}
GaleServerInitializer.java 文件源码
项目:gale
阅读 31
收藏 0
点赞 0
评论 0
@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);
}
HttpClientInitializer.java 文件源码
项目:SI
阅读 25
收藏 0
点赞 0
评论 0
@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));
}
URILoader.java 文件源码
项目:KIARA
阅读 41
收藏 0
点赞 0
评论 0
@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);
}
HttpUploadClientIntializer.java 文件源码
项目:netty4study
阅读 22
收藏 0
点赞 0
评论 0
@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());
}
HttpSnoopClientInitializer.java 文件源码
项目:netty4study
阅读 19
收藏 0
点赞 0
评论 0
@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());
}
NettyClientInit.java 文件源码
项目:jus
阅读 23
收藏 0
点赞 0
评论 0
@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);
}
ApiServerChannelInitializer.java 文件源码
项目:kha
阅读 23
收藏 0
点赞 0
评论 0
@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);
}
HttpUploadClientIntializer.java 文件源码
项目:netty-netty-5.0.0.Alpha1
阅读 17
收藏 0
点赞 0
评论 0
@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());
}
HttpSnoopClientInitializer.java 文件源码
项目:netty-netty-5.0.0.Alpha1
阅读 18
收藏 0
点赞 0
评论 0
@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());
}
PortUnificationHandler.java 文件源码
项目:mockserver
阅读 41
收藏 0
点赞 0
评论 0
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);
}
HTTPInitializer.java 文件源码
项目:stork
阅读 27
收藏 0
点赞 0
评论 0
/**
* 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));
}
NettyHttpClient.java 文件源码
项目:GitHub
阅读 21
收藏 0
点赞 0
评论 0
@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);
}
NettyHttpClient.java 文件源码
项目:GitHub
阅读 46
收藏 0
点赞 0
评论 0
@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);
}
Netty4HttpServerTransport.java 文件源码
项目:elasticsearch_my
阅读 22
收藏 0
点赞 0
评论 0
@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);
}
Server.java 文件源码
项目:qonduit
阅读 26
收藏 0
点赞 0
评论 0
protected ChannelHandler setupHttpChannel(Configuration config, SslContext sslCtx) {
return new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) throws Exception {
ch.pipeline().addLast("ssl", new NonSslRedirectHandler(config, sslCtx));
ch.pipeline().addLast("encoder", new HttpResponseEncoder());
ch.pipeline().addLast("decoder", new HttpRequestDecoder());
ch.pipeline().addLast("compressor", new HttpContentCompressor());
ch.pipeline().addLast("decompressor", new HttpContentDecompressor());
ch.pipeline().addLast("aggregator", new HttpObjectAggregator(8192));
ch.pipeline().addLast("chunker", new ChunkedWriteHandler());
final Configuration.Cors corsCfg = config.getHttp().getCors();
final CorsConfig.Builder ccb;
if (corsCfg.isAllowAnyOrigin()) {
ccb = new CorsConfig.Builder();
} else {
ccb = new CorsConfig.Builder(corsCfg.getAllowedOrigins().stream().toArray(String[]::new));
}
if (corsCfg.isAllowNullOrigin()) {
ccb.allowNullOrigin();
}
if (corsCfg.isAllowCredentials()) {
ccb.allowCredentials();
}
corsCfg.getAllowedMethods().stream().map(HttpMethod::valueOf).forEach(ccb::allowedRequestMethods);
corsCfg.getAllowedHeaders().forEach(ccb::allowedRequestHeaders);
CorsConfig cors = ccb.build();
LOG.trace("Cors configuration: {}", cors);
ch.pipeline().addLast("cors", new CorsHandler(cors));
ch.pipeline().addLast("queryDecoder", new qonduit.netty.http.HttpRequestDecoder(config));
ch.pipeline().addLast("strict", new StrictTransportHandler(config));
ch.pipeline().addLast("login", new X509LoginRequestHandler(config));
ch.pipeline().addLast("doLogin", new BasicAuthLoginRequestHandler(config));
ch.pipeline().addLast("error", new HttpExceptionHandler());
}
};
}
TestServer.java 文件源码
项目:qonduit
阅读 23
收藏 0
点赞 0
评论 0
@Override
protected ChannelHandler setupHttpChannel(Configuration config, SslContext sslCtx) {
return new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) throws Exception {
ch.pipeline().addLast("ssl", new NonSslRedirectHandler(config, sslCtx));
ch.pipeline().addLast("decompressor", new HttpContentDecompressor());
ch.pipeline().addLast("decoder", new HttpRequestDecoder());
ch.pipeline().addLast("aggregator", new HttpObjectAggregator(8192));
ch.pipeline().addLast("queryDecoder", new qonduit.netty.http.HttpRequestDecoder(config));
ch.pipeline().addLast("capture", httpRequests);
}
};
}
ResponseTextIntercept.java 文件源码
项目:proxyee-down
阅读 18
收藏 0
点赞 0
评论 0
@Override
public void afterResponse(Channel clientChannel, Channel proxyChannel, HttpResponse httpResponse,
HttpProxyInterceptPipeline pipeline) throws Exception {
if (match(httpResponse, pipeline)) {
isMatch = true;
//解压gzip响应
if ("gzip".equalsIgnoreCase(httpResponse.headers().get(HttpHeaderNames.CONTENT_ENCODING))) {
isGzip = true;
pipeline.reset3();
proxyChannel.pipeline().addAfter("httpCodec", "decompress", new HttpContentDecompressor());
proxyChannel.pipeline().fireChannelRead(httpResponse);
} else {
if (isGzip) {
httpResponse.headers().set(HttpHeaderNames.CONTENT_ENCODING, HttpHeaderValues.GZIP);
}
contentBuf = PooledByteBufAllocator.DEFAULT.buffer();
/*contentBuf.writeBytes(hookResponse().getBytes());
for (HttpProxyIntercept intercept : pipeline) {
if (intercept != this && intercept instanceof ResponseTextIntercept) {
ResponseTextIntercept textIntercept = (ResponseTextIntercept) intercept;
if (textIntercept.match(httpResponse, pipeline)) {
contentBuf.writeBytes(textIntercept.hookResponse().getBytes());
}
}
}*/
}
//直接调用默认拦截器,跳过下载拦截器
pipeline.getDefault()
.afterResponse(clientChannel, proxyChannel, httpResponse, pipeline);
} else {
isMatch = false;
pipeline.afterResponse(clientChannel, proxyChannel, httpResponse);
}
}
NettyHttpClient.java 文件源码
项目:PriorityOkHttp
阅读 23
收藏 0
点赞 0
评论 0
@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) {
SSLContext sslContext = SslContextBuilder.localhost();
SSLEngine engine = 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);
}
NettyHttpClient.java 文件源码
项目:Okhttp
阅读 32
收藏 0
点赞 0
评论 0
@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);
}
TestServer.java 文件源码
项目:timely
阅读 31
收藏 0
点赞 0
评论 0
@Override
protected ChannelHandler setupHttpChannel(Configuration config, SslContext sslCtx) {
return new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) throws Exception {
ch.pipeline().addLast("ssl", new NonSslRedirectHandler(config, sslCtx));
ch.pipeline().addLast("decompressor", new HttpContentDecompressor());
ch.pipeline().addLast("decoder", new HttpRequestDecoder());
ch.pipeline().addLast("aggregator", new HttpObjectAggregator(8192));
ch.pipeline().addLast("queryDecoder", new timely.netty.http.HttpRequestDecoder(config));
ch.pipeline().addLast("capture", httpRequests);
}
};
}
ChannelManager.java 文件源码
项目:megaphone
阅读 29
收藏 0
点赞 0
评论 0
private HttpContentDecompressor newHttpContentDecompressor() {
if (config.isKeepEncodingHeader())
return new HttpContentDecompressor() {
@Override
protected String getTargetContentEncoding(String contentEncoding) throws Exception {
return contentEncoding;
}
};
else
return new HttpContentDecompressor();
}