Search in sources :

Example 1 with Http2ClientUpgradeCodec

use of io.netty.handler.codec.http2.Http2ClientUpgradeCodec 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;
}
Also used : Http2ClientUpgradeCodec(io.netty.handler.codec.http2.Http2ClientUpgradeCodec) HttpClientCodec(io.netty.handler.codec.http.HttpClientCodec) HttpClientUpgradeHandler(io.netty.handler.codec.http.HttpClientUpgradeHandler)

Example 2 with Http2ClientUpgradeCodec

use of io.netty.handler.codec.http2.Http2ClientUpgradeCodec in project ballerina by ballerina-lang.

the class HTTP2ClientInitializer method configureClearText.

/**
 * Configure the pipeline for a cleartext upgrade from HTTP to HTTP/2.
 */
private void configureClearText(SocketChannel ch) {
    HttpClientCodec sourceCodec = new HttpClientCodec();
    Http2ClientUpgradeCodec upgradeCodec = new Http2ClientUpgradeCodec(connectionHandler);
    HttpClientUpgradeHandler upgradeHandler = new HttpClientUpgradeHandler(sourceCodec, upgradeCodec, 65536);
    ch.pipeline().addLast(sourceCodec, upgradeHandler, new UpgradeRequestHandler(), new UserEventLogger());
}
Also used : Http2ClientUpgradeCodec(io.netty.handler.codec.http2.Http2ClientUpgradeCodec) HttpClientCodec(io.netty.handler.codec.http.HttpClientCodec) HttpClientUpgradeHandler(io.netty.handler.codec.http.HttpClientUpgradeHandler)

Example 3 with Http2ClientUpgradeCodec

use of io.netty.handler.codec.http2.Http2ClientUpgradeCodec in project netty by netty.

the class Http2ClientInitializer method configureClearText.

/**
 * Configure the pipeline for a cleartext upgrade from HTTP to HTTP/2.
 */
private void configureClearText(SocketChannel ch) {
    HttpClientCodec sourceCodec = new HttpClientCodec();
    Http2ClientUpgradeCodec upgradeCodec = new Http2ClientUpgradeCodec(connectionHandler);
    HttpClientUpgradeHandler upgradeHandler = new HttpClientUpgradeHandler(sourceCodec, upgradeCodec, 65536);
    ch.pipeline().addLast(sourceCodec, upgradeHandler, new UpgradeRequestHandler(), new UserEventLogger());
}
Also used : Http2ClientUpgradeCodec(io.netty.handler.codec.http2.Http2ClientUpgradeCodec) HttpClientCodec(io.netty.handler.codec.http.HttpClientCodec) HttpClientUpgradeHandler(io.netty.handler.codec.http.HttpClientUpgradeHandler)

Example 4 with Http2ClientUpgradeCodec

use of io.netty.handler.codec.http2.Http2ClientUpgradeCodec in project rest.li by linkedin.

the class Http2ChannelInitializer method configureClearText.

/**
 * Configure the pipeline for HTTP/2 clear text.
 */
private void configureClearText(NioSocketChannel channel) {
    final HttpClientCodec sourceCodec = new HttpClientCodec(_maxInitialLineLength, _maxHeaderSize, _maxChunkSize);
    UnsupportedHandler unsupportedHandler = new UnsupportedHandler();
    Http2MultiplexHandler multiplexHandler = new Http2MultiplexHandler(unsupportedHandler, unsupportedHandler);
    Http2ClientUpgradeCodec upgradeCodec = new Http2ClientUpgradeCodec((Http2ConnectionHandler) Http2FrameCodecBuilder.forClient().initialSettings(createHttp2Settings()).build(), multiplexHandler);
    final ChannelPromise upgradePromise = channel.newPromise();
    channel.attr(NettyChannelAttributes.INITIALIZATION_FUTURE).set(upgradePromise);
    channel.pipeline().addLast(sourceCodec);
    channel.pipeline().addLast(new HttpClientUpgradeHandler(sourceCodec, upgradeCodec, _maxContentLength));
    channel.pipeline().addLast(new Http2ProtocolUpgradeHandler(upgradePromise));
}
Also used : UnsupportedHandler(com.linkedin.r2.netty.handler.http2.UnsupportedHandler) Http2MultiplexHandler(io.netty.handler.codec.http2.Http2MultiplexHandler) Http2ProtocolUpgradeHandler(com.linkedin.r2.netty.handler.http2.Http2ProtocolUpgradeHandler) Http2ClientUpgradeCodec(io.netty.handler.codec.http2.Http2ClientUpgradeCodec) ChannelPromise(io.netty.channel.ChannelPromise) HttpClientCodec(io.netty.handler.codec.http.HttpClientCodec) HttpClientUpgradeHandler(io.netty.handler.codec.http.HttpClientUpgradeHandler)

Example 5 with Http2ClientUpgradeCodec

use of io.netty.handler.codec.http2.Http2ClientUpgradeCodec in project rest.li by linkedin.

the class Http2ClientPipelineInitializer method configureHttpPipeline.

/**
 * Sets up HTTP/2 over TCP through protocol upgrade (h2c) pipeline
 */
private void configureHttpPipeline(Channel channel, Http2Connection connection) throws Exception {
    Http2StreamCodec http2Codec = new Http2StreamCodecBuilder().connection(connection).maxContentLength(_maxResponseSize).gracefulShutdownTimeoutMillis(_gracefulShutdownTimeout).build();
    HttpClientCodec sourceCodec = new HttpClientCodec(MAX_INITIAL_LINE_LENGTH, _maxHeaderSize, _maxChunkSize);
    Http2ClientUpgradeCodec upgradeCodec = new Http2ClientUpgradeCodec(http2Codec);
    HttpClientUpgradeHandler upgradeHandler = new HttpClientUpgradeHandler(sourceCodec, upgradeCodec, MAX_CLIENT_UPGRADE_CONTENT_LENGTH);
    Http2SchemeHandler schemeHandler = new Http2SchemeHandler(HttpScheme.HTTP.toString());
    Http2UpgradeHandler upgradeRequestHandler = new Http2UpgradeHandler();
    Http2StreamResponseHandler responseHandler = new Http2StreamResponseHandler();
    channel.pipeline().addLast("sourceCodec", sourceCodec);
    channel.pipeline().addLast("upgradeHandler", upgradeHandler);
    channel.pipeline().addLast("upgradeRequestHandler", upgradeRequestHandler);
    channel.pipeline().addLast("schemeHandler", schemeHandler);
    channel.pipeline().addLast("responseHandler", responseHandler);
}
Also used : Http2ClientUpgradeCodec(io.netty.handler.codec.http2.Http2ClientUpgradeCodec) HttpClientCodec(io.netty.handler.codec.http.HttpClientCodec) HttpClientUpgradeHandler(io.netty.handler.codec.http.HttpClientUpgradeHandler)

Aggregations

HttpClientCodec (io.netty.handler.codec.http.HttpClientCodec)5 HttpClientUpgradeHandler (io.netty.handler.codec.http.HttpClientUpgradeHandler)5 Http2ClientUpgradeCodec (io.netty.handler.codec.http2.Http2ClientUpgradeCodec)5 Http2ProtocolUpgradeHandler (com.linkedin.r2.netty.handler.http2.Http2ProtocolUpgradeHandler)1 UnsupportedHandler (com.linkedin.r2.netty.handler.http2.UnsupportedHandler)1 ChannelPromise (io.netty.channel.ChannelPromise)1 Http2MultiplexHandler (io.netty.handler.codec.http2.Http2MultiplexHandler)1