use of software.amazon.awssdk.http.nio.netty.internal.ChannelAttributeKey.HTTP2_CONNECTION in project aws-sdk-java-v2 by aws.
the class ChannelPipelineInitializer method configureHttp2.
private void configureHttp2(Channel ch, ChannelPipeline pipeline) {
// Using Http2FrameCodecBuilder and Http2MultiplexHandler based on 4.1.37 release notes
// https://netty.io/news/2019/06/28/4-1-37-Final.html
Http2FrameCodec codec = Http2FrameCodecBuilder.forClient().headerSensitivityDetector((name, value) -> lowerCase(name.toString()).equals("authorization")).initialSettings(Http2Settings.defaultSettings().initialWindowSize(clientInitialWindowSize)).frameLogger(new Http2FrameLogger(LogLevel.DEBUG)).build();
// Connection listeners have higher priority than handlers, in the eyes of the Http2FrameCodec. The Http2FrameCodec will
// close any connections when a GOAWAY is received, but we'd like to send a "GOAWAY happened" exception instead of just
// closing the connection. Because of this, we use a go-away listener instead of a handler, so that we can send the
// exception before the Http2FrameCodec closes the connection itself.
codec.connection().addListener(new Http2GoAwayEventListener(ch));
pipeline.addLast(codec);
ch.attr(HTTP2_CONNECTION).set(codec.connection());
ch.attr(HTTP2_INITIAL_WINDOW_SIZE).set(clientInitialWindowSize);
pipeline.addLast(new Http2MultiplexHandler(new NoOpChannelInitializer()));
pipeline.addLast(new Http2SettingsFrameHandler(ch, clientMaxStreams, channelPoolRef));
if (healthCheckPingPeriod == null) {
pipeline.addLast(new Http2PingHandler(HTTP2_CONNECTION_PING_TIMEOUT_SECONDS * 1_000));
} else if (healthCheckPingPeriod.toMillis() > 0) {
pipeline.addLast(new Http2PingHandler(saturatedCast(healthCheckPingPeriod.toMillis())));
}
}
Aggregations