Search in sources :

Example 1 with SessionResumptionSslHandler

use of com.linkedin.r2.netty.handler.common.SessionResumptionSslHandler in project rest.li by linkedin.

the class HttpChannelInitializer method initChannel.

@Override
protected void initChannel(NioSocketChannel channel) {
    if (_ssl) {
        channel.pipeline().addLast(SessionResumptionSslHandler.PIPELINE_SESSION_RESUMPTION_HANDLER, new SessionResumptionSslHandler(_sslContext, _sslParameters, _enableSSLSessionResumption, _sslHandShakeTimeout));
    }
    channel.pipeline().addLast("codec", new HttpClientCodec(_maxInitialLineLength, _maxHeaderSize, _maxChunkSize));
    channel.pipeline().addLast("outboundRestRequestEncoder", HttpMessageEncoders.newRestRequestEncoder());
    channel.pipeline().addLast("outboundStreamDataEncoder", HttpMessageEncoders.newDataEncoder());
    channel.pipeline().addLast("outboundStreamRequestEncoder", HttpMessageEncoders.newStreamRequestEncoder());
    channel.pipeline().addLast("inboundDataDecoder", HttpMessageDecoders.newDataDecoder());
    channel.pipeline().addLast("inboundRequestDecoder", HttpMessageDecoders.newResponseDecoder());
    channel.pipeline().addLast("schemeHandler", new SchemeHandler(_ssl ? HttpScheme.HTTPS.toString() : HttpScheme.HTTP.toString()));
    channel.pipeline().addLast("streamDuplexHandler", new ClientEntityStreamHandler(_maxContentLength));
    channel.pipeline().addLast("timeoutHandler", new CancelTimeoutHandler());
    channel.pipeline().addLast("channelPoolHandler", new ChannelLifecycleHandler(RECYCLE_CHANNEL));
}
Also used : ChannelLifecycleHandler(com.linkedin.r2.netty.handler.common.ChannelLifecycleHandler) SessionResumptionSslHandler(com.linkedin.r2.netty.handler.common.SessionResumptionSslHandler) ClientEntityStreamHandler(com.linkedin.r2.netty.handler.common.ClientEntityStreamHandler) CancelTimeoutHandler(com.linkedin.r2.netty.handler.common.CancelTimeoutHandler) SchemeHandler(com.linkedin.r2.netty.handler.common.SchemeHandler) HttpClientCodec(io.netty.handler.codec.http.HttpClientCodec)

Example 2 with SessionResumptionSslHandler

use of com.linkedin.r2.netty.handler.common.SessionResumptionSslHandler in project rest.li by linkedin.

the class RAPStreamClientPipelineInitializer method initChannel.

@Override
protected void initChannel(NioSocketChannel ch) {
    if (_sslContext != null) {
        ch.pipeline().addLast(SessionResumptionSslHandler.PIPELINE_SESSION_RESUMPTION_HANDLER, new SessionResumptionSslHandler(_sslContext, _sslParameters, _enableSSLSessionResumption, _sslHandShakeTimeout));
    }
    ch.pipeline().addLast("codec", new HttpClientCodec(4096, _maxHeaderSize, _maxChunkSize));
    ch.pipeline().addLast("rapFullRequestEncoder", new RAPStreamFullRequestEncoder());
    ch.pipeline().addLast("rapEncoder", new RAPStreamRequestEncoder());
    ch.pipeline().addLast("rapDecoder", new RAPStreamResponseDecoder(_maxResponseSize));
    // the response handler catches the exceptions thrown by other layers. By consequence no handlers that throw exceptions
    // should be after this one, otherwise the exception won't be caught and managed by R2
    ch.pipeline().addLast("responseHandler", new RAPStreamResponseHandler());
    ch.pipeline().addLast("channelManager", new ChannelPoolStreamHandler());
}
Also used : SessionResumptionSslHandler(com.linkedin.r2.netty.handler.common.SessionResumptionSslHandler) HttpClientCodec(io.netty.handler.codec.http.HttpClientCodec)

Example 3 with SessionResumptionSslHandler

use of com.linkedin.r2.netty.handler.common.SessionResumptionSslHandler in project rest.li by linkedin.

the class Http2ChannelInitializer method configureSsl.

/**
 * Configure the pipeline for TLS ALPN negotiation to HTTP/2.
 */
private void configureSsl(NioSocketChannel channel) throws SSLException {
    final SslContext sslCtx = createSslContext();
    final ChannelPromise alpnPromise = channel.newPromise();
    channel.attr(NettyChannelAttributes.INITIALIZATION_FUTURE).set(alpnPromise);
    channel.pipeline().addLast(SessionResumptionSslHandler.PIPELINE_SESSION_RESUMPTION_HANDLER, new SessionResumptionSslHandler(sslCtx, _enableSSLSessionResumption, _sslHandShakeTimeout));
    channel.pipeline().addLast(new Http2AlpnHandler(alpnPromise, createHttp2Settings()));
}
Also used : SessionResumptionSslHandler(com.linkedin.r2.netty.handler.common.SessionResumptionSslHandler) ChannelPromise(io.netty.channel.ChannelPromise) Http2AlpnHandler(com.linkedin.r2.netty.handler.http2.Http2AlpnHandler) JdkSslContext(io.netty.handler.ssl.JdkSslContext) SslContext(io.netty.handler.ssl.SslContext)

Example 4 with SessionResumptionSslHandler

use of com.linkedin.r2.netty.handler.common.SessionResumptionSslHandler in project rest.li by linkedin.

the class Http2AlpnHandler method handlerAdded.

@Override
public void handlerAdded(ChannelHandlerContext ctx) {
    _alpnPromise = ctx.channel().newPromise();
    // the class will take care of establishing the SSL connection
    ctx.pipeline().addFirst(SessionResumptionSslHandler.PIPELINE_SESSION_RESUMPTION_HANDLER, new SessionResumptionSslHandler(_sslContext, _enableSSLSessionResumption, _sslHandShakeTimeout));
    // Fail the ALPN promise when channel is closed
    ctx.channel().closeFuture().addListener(future -> {
        if (!_alpnPromise.isDone()) {
            _alpnPromise.setFailure(new ChannelException("HTTP/2 ALPN did not complete before channel closed"));
        }
    });
}
Also used : SessionResumptionSslHandler(com.linkedin.r2.netty.handler.common.SessionResumptionSslHandler) ChannelException(io.netty.channel.ChannelException)

Aggregations

SessionResumptionSslHandler (com.linkedin.r2.netty.handler.common.SessionResumptionSslHandler)4 HttpClientCodec (io.netty.handler.codec.http.HttpClientCodec)2 CancelTimeoutHandler (com.linkedin.r2.netty.handler.common.CancelTimeoutHandler)1 ChannelLifecycleHandler (com.linkedin.r2.netty.handler.common.ChannelLifecycleHandler)1 ClientEntityStreamHandler (com.linkedin.r2.netty.handler.common.ClientEntityStreamHandler)1 SchemeHandler (com.linkedin.r2.netty.handler.common.SchemeHandler)1 Http2AlpnHandler (com.linkedin.r2.netty.handler.http2.Http2AlpnHandler)1 ChannelException (io.netty.channel.ChannelException)1 ChannelPromise (io.netty.channel.ChannelPromise)1 JdkSslContext (io.netty.handler.ssl.JdkSslContext)1 SslContext (io.netty.handler.ssl.SslContext)1