类 io.netty.handler.codec.http2.InboundHttp2ToHttpAdapterBuilder 源码实例Demo

下面列出了怎么用 io.netty.handler.codec.http2.InboundHttp2ToHttpAdapterBuilder 的API类实例代码及写法,或者点击链接到github查看源代码。


@Override
public void initChannel(SocketChannel ch) throws Exception {
    final Http2Connection connection = new DefaultHttp2Connection(false);
    connectionHandler = new HttpToHttp2ConnectionHandlerBuilder()
            .frameListener(new DelegatingDecompressorFrameListener(
                    connection,
                    new InboundHttp2ToHttpAdapterBuilder(connection)
                            .maxContentLength(maxContentLength)
                            .propagateSettings(true)
                            .build()))
            .frameLogger(logger)
            .connection(connection)
            .build();
    responseHandler = new HttpResponseHandler();
    settingsHandler = new Http2SettingsHandler(ch.newPromise());
    if (sslCtx != null) {
        configureSsl(ch);
    } else {
        configureClearText(ch);
    }
}
 

@Override
public void initChannel(SocketChannel ch) {
    final Http2Connection connection = new DefaultHttp2Connection(false);
    connectionHandler = new HttpToHttp2ConnectionHandlerBuilder()
            .frameListener(new DelegatingDecompressorFrameListener(
                    connection,
                    new InboundHttp2ToHttpAdapterBuilder(connection)
                            .maxContentLength(maxContentLength)
                            .propagateSettings(true)
                            .build()))
            .frameLogger(logger)
            .connection(connection)
            .build();
    responseHandler = new Http2ResponseHandler();
    settingsHandler = new Http2SettingsHandler(ch.newPromise());
    if (sslCtx != null) {
        configureSsl(ch);
    } else {
        configureClearText(ch);
    }
}
 
源代码3 项目: sofa-rpc   文件: Http2ClientInitializer.java

@Override
public void initChannel(SocketChannel ch) throws Exception {
    final Http2Connection connection = new DefaultHttp2Connection(false);
    connectionHandler = new HttpToHttp2ConnectionHandlerBuilder()
        .frameListener(
            new DelegatingDecompressorFrameListener(connection, new InboundHttp2ToHttpAdapterBuilder(connection)
                .maxContentLength(transportConfig.getPayload()).propagateSettings(true).build()))
        .connection(connection).build();
    responseHandler = new Http2ClientChannelHandler();
    settingsHandler = new Http2SettingsHandler(ch.newPromise());
    String protocol = transportConfig.getProviderInfo().getProtocolType();
    if (RpcConstants.PROTOCOL_TYPE_H2.equals(protocol)) {
        configureSsl(ch);
    } else if (RpcConstants.PROTOCOL_TYPE_H2C.equals(protocol)) {
        if (!useH2cPriorKnowledge) {
            configureClearTextWithHttpUpgrade(ch);
        } else {
            configureClearTextWithPriorKnowledge(ch);
        }
    }
}
 
源代码4 项目: nitmproxy   文件: Http2FrontendHandler.java

@Override
public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
    LOGGER.info("{} : handlerAdded", connectionInfo);

    Http2Connection connection = new DefaultHttp2Connection(true);
    ChannelHandler http2ConnHandler = new HttpToHttp2ConnectionHandlerBuilder()
            .frameListener(new DelegatingDecompressorFrameListener(
                    connection,
                    new InboundHttp2ToHttpAdapterBuilder(connection)
                            .maxContentLength(master.config().getMaxContentLength())
                            .propagateSettings(true)
                            .build()))
            .connection(connection)
            .frameLogger(new Http2FrameLogger(LogLevel.DEBUG))
            .build();
    ctx.pipeline()
       .addBefore(ctx.name(), null, http2ConnHandler)
       .addBefore(ctx.name(), null, new Http2Handler());
}
 
源代码5 项目: nitmproxy   文件: Http2BackendHandler.java

@Override
public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
    LOGGER.info("{} : handlerAdded", connectionInfo);

    Http2Connection connection = new DefaultHttp2Connection(false);
    ChannelHandler http2ConnHandler = new HttpToHttp2ConnectionHandlerBuilder()
            .frameListener(new DelegatingDecompressorFrameListener(
                    connection,
                    new InboundHttp2ToHttpAdapterBuilder(connection)
                            .maxContentLength(master.config().getMaxContentLength())
                            .propagateSettings(true)
                            .build()))
            .frameLogger(new Http2FrameLogger(LogLevel.DEBUG))
            .connection(connection)
            .build();
    ctx.pipeline()
       .addBefore(ctx.name(), null, http2ConnHandler)
       .addBefore(ctx.name(), null, new Http2Handler());
}
 
源代码6 项目: netty-4.1.22   文件: Http2OrHttpHandler.java

private static void configureHttp2(ChannelHandlerContext ctx) {
    DefaultHttp2Connection connection = new DefaultHttp2Connection(true);
    InboundHttp2ToHttpAdapter listener = new InboundHttp2ToHttpAdapterBuilder(connection)
            .propagateSettings(true).validateHttpHeaders(false)
            .maxContentLength(MAX_CONTENT_LENGTH).build();

    ctx.pipeline().addLast(new HttpToHttp2ConnectionHandlerBuilder()
            .frameListener(listener)
            // .frameLogger(TilesHttp2ToHttpHandler.logger)
            .connection(connection).build());

    ctx.pipeline().addLast(new Http2RequestHandler());
}
 
源代码7 项目: armeria   文件: THttp2Client.java

@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 HttpClientCodec sourceCodec = new HttpClientCodec();
        final HttpClientUpgradeHandler upgradeHandler = new HttpClientUpgradeHandler(
                sourceCodec, new Http2ClientUpgradeCodec(connHandler), 65536);

        p.addLast(sourceCodec, upgradeHandler, new UpgradeRequestHandler());
    }
}
 
源代码8 项目: tutorials   文件: Http2Util.java

public static ApplicationProtocolNegotiationHandler getClientAPNHandler(int maxContentLength, Http2SettingsHandler settingsHandler, Http2ClientResponseHandler responseHandler) {
    final Http2FrameLogger logger = new Http2FrameLogger(INFO, Http2Util.class);
    final Http2Connection connection = new DefaultHttp2Connection(false);

    HttpToHttp2ConnectionHandler connectionHandler = new HttpToHttp2ConnectionHandlerBuilder()
        .frameListener(new DelegatingDecompressorFrameListener(connection, new InboundHttp2ToHttpAdapterBuilder(connection).maxContentLength(maxContentLength)
        .propagateSettings(true)
        .build()))
        .frameLogger(logger)
        .connection(connection)
        .build();

    ApplicationProtocolNegotiationHandler clientAPNHandler = new ApplicationProtocolNegotiationHandler(ApplicationProtocolNames.HTTP_2) {
        @Override
        protected void configurePipeline(ChannelHandlerContext ctx, String protocol) {
            if (ApplicationProtocolNames.HTTP_2.equals(protocol)) {
                ChannelPipeline p = ctx.pipeline();
                p.addLast(connectionHandler);
                p.addLast(settingsHandler, responseHandler);
                return;
            }
            ctx.close();
            throw new IllegalStateException("Protocol: " + protocol + " not supported");
        }
    };

    return clientAPNHandler;

}
 
 类方法
 同包方法