io.netty.handler.codec.http2.Http2FrameCodecBuilder # headerSensitivityDetector ( ) 源码实例Demo

下面列出了 io.netty.handler.codec.http2.Http2FrameCodecBuilder # headerSensitivityDetector ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。


@Override
public void init(final Channel channel) {
    final Http2FrameCodecBuilder multiplexCodecBuilder = forServer()
            // We do not want close to trigger graceful closure (go away), instead when user triggers a graceful
            // close, we do the appropriate go away handling.
            .decoupleCloseAndGoAway(true)
            // We don't want to rely upon Netty to manage the graceful close timeout, because we expect
            // the user to apply their own timeout at the call site.
            .gracefulShutdownTimeoutMillis(-1);

    final BiPredicate<CharSequence, CharSequence> headersSensitivityDetector =
            config.headersSensitivityDetector();
    multiplexCodecBuilder.headerSensitivityDetector(headersSensitivityDetector::test);

    final String frameLoggerName = config.frameLoggerName();
    if (frameLoggerName != null) {
        multiplexCodecBuilder.frameLogger(new Http2FrameLogger(TRACE, frameLoggerName));
    }

    // TODO(scott): more configuration. header validation, settings stream, etc...

    channel.pipeline().addLast(multiplexCodecBuilder.build(), new Http2MultiplexHandler(streamChannelInitializer));
}
 

@Override
public void init(final Channel channel) {
    final Http2FrameCodecBuilder multiplexCodecBuilder = forClient()
            // We do not want close to trigger graceful closure (go away), instead when user triggers a graceful
            // close, we do the appropriate go away handling.
            .decoupleCloseAndGoAway(true)
            // The max concurrent streams is made available via a publisher and may be consumed asynchronously
            // (e.g. when offloading is enabled), so we manually control the SETTINGS ACK frames.
            .autoAckSettingsFrame(false)
            // We don't want to rely upon Netty to manage the graceful close timeout, because we expect
            // the user to apply their own timeout at the call site.
            .gracefulShutdownTimeoutMillis(-1);

    // Notify server that this client does not support server push and request it to be disabled.
    multiplexCodecBuilder.initialSettings().pushEnabled(false).maxConcurrentStreams(0L);

    final BiPredicate<CharSequence, CharSequence> headersSensitivityDetector =
            config.headersSensitivityDetector();
    multiplexCodecBuilder.headerSensitivityDetector(headersSensitivityDetector::test);

    final String frameLoggerName = config.frameLoggerName();
    if (frameLoggerName != null) {
        multiplexCodecBuilder.frameLogger(new Http2FrameLogger(TRACE, frameLoggerName));
    }

    // TODO(scott): more configuration. header validation, settings stream, etc...

    channel.pipeline().addLast(multiplexCodecBuilder.build(),
            new Http2MultiplexHandler(H2PushStreamHandler.INSTANCE));
}