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

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


@Override
public void initChannel(SocketChannel ch) throws Exception {
    final Http2Connection connection = new DefaultHttp2Connection(false);

    connectionHandler = new HttpToHttp2ConnectionHandler(connection,
            frameReader(),
            frameWriter(),
            new DelegatingDecompressorFrameListener(connection,
                    new InboundHttp2ToHttpAdapter.Builder(connection)
                            .maxContentLength(maxContentLength)
                            .propagateSettings(true)
                            .build()));
    responseHandler = new HttpResponseHandler();
    settingsHandler = new Http2SettingsHandler(ch.newPromise());
    if (sslCtx != null) {
        configureSsl(ch);
    } else {
        configureClearText(ch);
    }
}
 

@Override
public void initChannel(SocketChannel ch) throws Exception {
    final Http2Connection connection = new DefaultHttp2Connection(false);
    final Http2FrameWriter frameWriter = frameWriter();
    connectionHandler = new HttpToHttp2ConnectionHandler(connection,
            frameReader(),
            frameWriter,
            new DelegatingDecompressorFrameListener(connection,
                    new InboundHttp2ToHttpAdapter.Builder(connection)
                            .maxContentLength(maxContentLength)
                            .propagateSettings(true)
                            .build()));
    responseHandler = new HttpResponseHandler();
    settingsHandler = new Http2SettingsHandler(ch.newPromise());
    configureClearText(ch);
}
 
源代码3 项目: 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());
}
 
 类方法
 同包方法