@Override protected void initChannel(SocketChannel channel) throws Exception { configureChannel(channel.config()); ChannelPipeline pipeline = channel.pipeline(); if (isSecure) { Assert.notNull(sslContext, "sslContext should not be null"); pipeline.addLast(sslContext.newHandler(channel.alloc(), uri.getHost(), uri.getPort())); } pipeline.addLast(new HttpClientCodec()); pipeline.addLast(new HttpObjectAggregator(maxResponseSize)); if (readTimeout > 0) { pipeline.addLast(new ReadTimeoutHandler(readTimeout, TimeUnit.MILLISECONDS)); } } });
private void enableSsl( ChannelHandlerContext ctx ) { ChannelPipeline p = ctx.pipeline(); p.addLast( sslCtx.newHandler( ctx.alloc() ) ); p.addLast( new TransportSelectionHandler( boltChannel, null, encryptionRequired, true, logging, boltProtocolFactory ) ); p.remove( this ); }
@Override public SslHandler newSSLHandler(SocketChannel channel) { return context.newHandler(channel.alloc()); } }
@Override public void initChannel(SocketChannel ch) throws Exception { final ChannelPipeline p = ch.pipeline(); final Http2Connection conn = new DefaultHttp2Connection(false); final HttpToHttp2ConnectionHandler connHandler = new HttpToHttp2ConnectionHandlerBuilder() .connection(conn) .frameListener(new DelegatingDecompressorFrameListener( conn, new InboundHttp2ToHttpAdapterBuilder(conn) .maxContentLength(Integer.MAX_VALUE) .propagateSettings(true).build())) .build(); clientHandler = new THttp2ClientHandler(ch.eventLoop()); if (sslCtx != null) { p.addLast(sslCtx.newHandler(p.channel().alloc())); p.addLast(connHandler); configureEndOfPipeline(p); } else { final Http1ClientCodec sourceCodec = new Http1ClientCodec(); final HttpClientUpgradeHandler upgradeHandler = new HttpClientUpgradeHandler( sourceCodec, new Http2ClientUpgradeCodec(connHandler), 65536); p.addLast(sourceCodec, upgradeHandler, new UpgradeRequestHandler()); } }
/** * Configure the pipeline for TLS NPN negotiation to HTTP/2. */ private void configureSsl(SocketChannel ch) { ch.pipeline().addLast(sslCtx.newHandler(ch.alloc()), new HttpVersionChooser(baseUri, container)); }
@Override public void initChannel(Channel channel) throws Exception { ChannelPipeline pipeline = channel.pipeline(); if (log.isDebugEnabled()) { pipeline.addLast(new LoggingHandler()); } if (sslContext != null) { pipeline.addLast("ssl", sslContext.newHandler(channel.alloc())); } pipeline.addLast("http-codec", new HttpClientCodec()); for (ChannelHandler handler : handlers) { pipeline.addLast(handler); } pipeline.addLast("chunkedWriter", new ChunkedWriteHandler()); } }
@Override public SslHandler newSSLHandler(SocketChannel channel, InetSocketAddress remoteEndpoint) { return context.newHandler( channel.alloc(), remoteEndpoint.getHostName(), remoteEndpoint.getPort()); } }
@Override protected void initChannel(SocketChannel channel) throws Exception { channel.pipeline().addLast("ssl", sslContext.newHandler(channel.alloc())) .addLast("handshake", new ServerHandshakeHandlerAdapter()); } }
@Override protected void initChannel(Channel channel) throws Exception { channel.pipeline() .addLast("timeout", new ReadTimeoutHandler(6000, TimeUnit.MILLISECONDS)); if (sslCtx != null) { channel.pipeline().addLast("ssl", sslCtx.newHandler(channel.alloc())); } channel.pipeline().addLast("codec", new HttpClientCodec()); channel.pipeline().addLast("handler", new HttpHandler(callback)); } }
@Override protected void initChannel(SocketChannel ch) { ChannelPipeline p = ch.pipeline(); if (sslCtx != null) { p.addLast(sslCtx.newHandler(ch.alloc(), host, port)); } p.addLast( new HttpClientCodec(), new HttpObjectAggregator(8192), WebSocketClientCompressionHandler.INSTANCE, handler ); } });
@Override protected void initChannel(Channel ch) throws Exception { final ChannelPipeline pipeline = ch.pipeline(); pipeline.addLast(new PassportStateOriginHandler()); if (connectionPoolConfig.isSecure()) { pipeline.addLast("ssl", sslContext.newHandler(ch.alloc())); } pipeline.addLast(HTTP_CODEC_HANDLER_NAME, new HttpClientCodec( BaseZuulChannelInitializer.MAX_INITIAL_LINE_LENGTH.get(), BaseZuulChannelInitializer.MAX_HEADER_SIZE.get(), BaseZuulChannelInitializer.MAX_CHUNK_SIZE.get(), false, false )); pipeline.addLast(PassportStateHttpClientHandler.PASSPORT_STATE_HTTP_CLIENT_HANDLER_NAME, new PassportStateHttpClientHandler()); pipeline.addLast("originNettyLogger", nettyLogger); pipeline.addLast(httpMetricsHandler); addMethodBindingHandler(pipeline); pipeline.addLast("httpLifecycle", new HttpClientLifecycleChannelHandler()); pipeline.addLast("connectionPoolHandler", connectionPoolHandler); }
@Override protected void initChannel(SocketChannel channel) throws Exception { configureChannel(channel.config()); ChannelPipeline pipeline = channel.pipeline(); if (isSecure) { Assert.notNull(sslContext, "sslContext should not be null"); pipeline.addLast(sslContext.newHandler(channel.alloc(), uri.getHost(), uri.getPort())); } pipeline.addLast(new HttpClientCodec()); pipeline.addLast(new HttpObjectAggregator(maxResponseSize)); if (readTimeout > 0) { pipeline.addLast(new ReadTimeoutHandler(readTimeout, TimeUnit.MILLISECONDS)); } } });
final SslHandler sslHandler = sslCtx.newHandler(ch.alloc(), remoteAddr.getHostString(), remoteAddr.getPort()); p.addLast(configureSslHandler(sslHandler)); p.addLast(TrafficLoggingHandler.CLIENT); p.addLast(new ChannelInboundHandlerAdapter() { private boolean handshakeFailed;
/** * Configure the pipeline for TLS NPN negotiation to HTTP/2. */ private void configureSsl(SocketChannel ch) { SslContext sslCtx = SslContextBuilder.build(); ChannelPipeline pipeline = ch.pipeline(); pipeline.addLast(sslCtx.newHandler(ch.alloc())); // We must wait for the handshake to finish and the protocol to be negotiated before configuring // the HTTP/2 components of the pipeline. pipeline.addLast(new ApplicationProtocolNegotiationHandler("") { @Override protected void configurePipeline(ChannelHandlerContext ctx, String protocol) { if (ApplicationProtocolNames.HTTP_2.equals(protocol)) { ChannelPipeline p = ctx.pipeline(); p.addLast(connectionHandler); configureEndOfPipeline(p); return; } ctx.close(); throw new IllegalStateException("unknown protocol: " + protocol); } }); }
@Override protected void initChannel(Channel ch) throws Exception { SslHandler sslHandler = sslContext.newHandler(ch.alloc()); sslHandler.engine().setEnabledProtocols(serverSslConfig.getProtocols()); addPassportHandler(pipeline); addTcpRelatedHandlers(pipeline); pipeline.addLast(new Http2FrameLoggingPerClientIpHandler()); pipeline.addLast("ssl", sslHandler); addSslInfoHandlers(pipeline, isSSlFromIntermediary); addSslClientCertChecks(pipeline); Http2ConnectionExpiryHandler connectionExpiryHandler = new Http2ConnectionExpiryHandler(maxRequestsPerConnection, maxRequestsPerConnectionInBrownout, connectionExpiry); pipeline.addLast("http2CodecSwapper", new Http2OrHttpHandler( new Http2StreamInitializer(ch, this::http1Handlers, http2MetricsChannelHandlers, connectionCloseHandler, connectionExpiryHandler), channelConfig,
/** * Configure the pipeline for TLS NPN negotiation to HTTP/2. */ private void configureSsl(SocketChannel ch) { SslContext sslCtx = SslContextBuilder.build(); ChannelPipeline pipeline = ch.pipeline(); pipeline.addLast(sslCtx.newHandler(ch.alloc())); // We must wait for the handshake to finish and the protocol to be negotiated before configuring // the HTTP/2 components of the pipeline. pipeline.addLast(new ApplicationProtocolNegotiationHandler("") { @Override protected void configurePipeline(ChannelHandlerContext ctx, String protocol) { if (ApplicationProtocolNames.HTTP_2.equals(protocol)) { ChannelPipeline p = ctx.pipeline(); p.addLast(connectionHandler); configureEndOfPipeline(p); return; } ctx.close(); throw new IllegalStateException("unknown protocol: " + protocol); } }); }
@Override protected void initChannel(Channel ch) throws Exception { SslHandler sslHandler = sslContext.newHandler(ch.alloc()); sslHandler.engine().setEnabledProtocols(sslContextFactory.getProtocols()); // Configure our pipeline of ChannelHandlerS. ChannelPipeline pipeline = ch.pipeline(); storeChannel(ch); addTimeoutHandlers(pipeline); addPassportHandler(pipeline); addTcpRelatedHandlers(pipeline); pipeline.addLast("ssl", sslHandler); addSslInfoHandlers(pipeline, isSSlFromIntermediary); addSslClientCertChecks(pipeline); addHttp1Handlers(pipeline); addHttpRelatedHandlers(pipeline); addZuulHandlers(pipeline); } }
@Override protected void initChannel(SocketChannel channel) throws Exception { channel.pipeline().addLast("ssl", sslContext.newHandler(channel.alloc(), address.host(), address.port())) .addLast("handshake", new ClientHandshakeHandlerAdapter(future)); } }
pipeline.addLast(sslContext.newHandler(ch.alloc())); pipeline.addLast(new LoggingHandler(logLevel)) ); pipeline.addLast(new IdleStateHandler( (int) serverConfiguration.getReadIdleTimeout().getSeconds(), (int) serverConfiguration.getWriteIdleTimeout().getSeconds(),
@Override protected void initChannel(SocketChannel ch) { ChannelPipeline pipeline = ch.pipeline(); try { if (sslCtx != null) { pipeline.addLast(sslCtx.newHandler(ch.alloc())); } pipeline.addLast(new HttpServerCodec()); pipeline.addLast(new HttpServerExpectContinueHandler()); if (useGZIP) { pipeline.addLast(new HttpContentCompressor()); } if (isWebSocket) { pipeline.addLast(new WebSocketHandler(blade)); } pipeline.addLast(new MergeRequestHandler()); pipeline.addLast(httpServerHandler); } catch (Exception e) { log.error("Add channel pipeline error", e); } }