use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpClientCodec in project benchmark by seelunzi.
the class ClientIniter method initChannel.
@Override
protected void initChannel(SocketChannel socketChannel) throws Exception {
ChannelPipeline pipeline = socketChannel.pipeline();
pipeline.addLast("stringD", new StringDecoder());
pipeline.addLast("stringC", new StringEncoder());
pipeline.addLast("http", new HttpClientCodec());
pipeline.addLast("chat", new ChatClientHandler());
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpClientCodec in project apn-proxy by apn-proxy.
the class ApnProxyRemoteForwardChannelInitializer method initChannel.
@Override
public void initChannel(SocketChannel channel) throws Exception {
ApnProxyRemote apnProxyRemote = uaChannel.attr(ApnProxyConnectionAttribute.ATTRIBUTE_KEY).get().getRemote();
channel.attr(ApnProxyConnectionAttribute.ATTRIBUTE_KEY).set(uaChannel.attr(ApnProxyConnectionAttribute.ATTRIBUTE_KEY).get());
ChannelPipeline pipeline = channel.pipeline();
pipeline.addLast("idlestate", new IdleStateHandler(0, 0, 3, TimeUnit.MINUTES));
pipeline.addLast("idlehandler", new ApnProxyIdleHandler());
if (apnProxyRemote.getRemoteListenType() == ApnProxyListenType.SSL) {
SSLEngine engine = ApnProxySSLContextFactory.createClientSSLEnginForRemoteAddress(apnProxyRemote.getRemoteHost(), apnProxyRemote.getRemotePort());
engine.setUseClientMode(true);
pipeline.addLast("ssl", new SslHandler(engine));
} else if (apnProxyRemote.getRemoteListenType() == ApnProxyListenType.AES) {
byte[] key = ((ApnProxyAESRemote) apnProxyRemote).getKey();
byte[] iv = ((ApnProxyAESRemote) apnProxyRemote).getIv();
pipeline.addLast("apnproxy.encrypt", new ApnProxyAESEncoder(key, iv));
pipeline.addLast("apnproxy.decrypt", new ApnProxyAESDecoder(key, iv));
}
pipeline.addLast("codec", new HttpClientCodec());
pipeline.addLast(ApnProxyRemoteForwardHandler.HANDLER_NAME, new ApnProxyRemoteForwardHandler(uaChannel, remoteChannelInactiveCallback));
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpClientCodec in project rest.li by linkedin.
the class RAPClientPipelineInitializer method initChannel.
@Override
protected void initChannel(NioSocketChannel ch) throws Exception {
ch.pipeline().addLast("codec", new HttpClientCodec(4096, _maxHeaderSize, _maxChunkSize));
ch.pipeline().addLast("rapFullRequestEncoder", new RAPFullRequestEncoder());
ch.pipeline().addLast("rapEncoder", new RAPRequestEncoder());
ch.pipeline().addLast("rapDecoder", new RAPResponseDecoder(_maxResponseSize));
ch.pipeline().addLast("responseHandler", new RAPStreamResponseHandler());
if (_sslContext != null) {
ch.pipeline().addLast("sslRequestHandler", new SslRequestHandler(_sslContext, _sslParameters));
}
ch.pipeline().addLast("channelManager", new ChannelPoolStreamHandler());
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpClientCodec in project rest.li by linkedin.
the class TestRAPClientCodec method testDecodeException.
@Test
public void testDecodeException() {
final EmbeddedChannel ch = new EmbeddedChannel(new HttpClientCodec(), new HttpObjectAggregator(65536), new RAPClientCodec());
// When we received an invalid message, a decode exception should be thrown out of the
// end of netty pipeline.
String junk = "Not a HTTP message\r\n";
try {
ch.writeInbound(Unpooled.copiedBuffer(junk, CHARSET));
Assert.fail("Should have thrown decode exception");
} catch (Exception ex) {
// expected.
}
ch.finish();
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpClientCodec in project rest.li by linkedin.
the class Http2InitializerHandler method configureHttpPipeline.
/**
* Sets up HTTP/2 over TCP through protocol upgrade (h2c) pipeline
*/
private void configureHttpPipeline(ChannelHandlerContext ctx, Request request) throws Exception {
Http2StreamCodec http2Codec = new Http2StreamCodecBuilder().connection(_connection).maxContentLength(_maxResponseSize).maxHeaderSize(_maxHeaderSize).gracefulShutdownTimeoutMillis(_gracefulShutdownTimeout).streamingTimeout(_streamingTimeout).scheduler(_scheduler).build();
HttpClientCodec sourceCodec = new HttpClientCodec(MAX_INITIAL_LINE_LENGTH, _maxHeaderSize, _maxChunkSize);
Http2ClientUpgradeCodec targetCodec = new Http2ClientUpgradeCodec(http2Codec);
HttpClientUpgradeHandler upgradeCodec = new HttpClientUpgradeHandler(sourceCodec, targetCodec, MAX_CLIENT_UPGRADE_CONTENT_LENGTH);
Http2SchemeHandler schemeHandler = new Http2SchemeHandler(HttpScheme.HTTP.toString());
String host = request.getURI().getAuthority();
int port = request.getURI().getPort();
String path = request.getURI().getPath();
Http2UpgradeHandler upgradeHandler = new Http2UpgradeHandler(host, port, path);
Http2StreamResponseHandler responseHandler = new Http2StreamResponseHandler();
Http2ChannelPoolHandler channelPoolHandler = new Http2ChannelPoolHandler();
ctx.pipeline().addBefore(ctx.name(), "sourceCodec", sourceCodec);
ctx.pipeline().addBefore(ctx.name(), "upgradeCodec", upgradeCodec);
ctx.pipeline().addBefore(ctx.name(), "upgradeHandler", upgradeHandler);
ctx.pipeline().addBefore(ctx.name(), "schemeHandler", schemeHandler);
ctx.pipeline().addBefore(ctx.name(), "responseHandler", responseHandler);
ctx.pipeline().addBefore(ctx.name(), "channelHandler", channelPoolHandler);
_setupComplete = true;
}
Aggregations