use of com.netflix.netty.common.Http2ConnectionCloseHandler in project zuul by Netflix.
the class Http2SslChannelInitializer method initChannel.
@Override
protected void initChannel(Channel ch) throws Exception {
SslHandler sslHandler = sslContext.newHandler(ch.alloc());
sslHandler.engine().setEnabledProtocols(serverSslConfig.getProtocols());
if (LOG.isDebugEnabled()) {
LOG.debug("ssl protocols supported: {}", String.join(", ", sslHandler.engine().getSupportedProtocols()));
LOG.debug("ssl protocols enabled: {}", String.join(", ", sslHandler.engine().getEnabledProtocols()));
LOG.debug("ssl ciphers supported: {}", String.join(", ", sslHandler.engine().getSupportedCipherSuites()));
LOG.debug("ssl ciphers enabled: {}", String.join(", ", sslHandler.engine().getEnabledCipherSuites()));
}
// Configure our pipeline of ChannelHandlerS.
ChannelPipeline pipeline = ch.pipeline();
storeChannel(ch);
addTimeoutHandlers(pipeline);
addPassportHandler(pipeline);
addTcpRelatedHandlers(pipeline);
pipeline.addLast(new Http2FrameLoggingPerClientIpHandler());
pipeline.addLast("ssl", sslHandler);
addSslInfoHandlers(pipeline, isSSlFromIntermediary);
addSslClientCertChecks(pipeline);
Http2MetricsChannelHandlers http2MetricsChannelHandlers = new Http2MetricsChannelHandlers(registry, "server", "http2-" + metricId);
Http2ConnectionCloseHandler connectionCloseHandler = new Http2ConnectionCloseHandler(registry);
Http2ConnectionExpiryHandler connectionExpiryHandler = new Http2ConnectionExpiryHandler(maxRequestsPerConnection, maxRequestsPerConnectionInBrownout, connectionExpiry);
pipeline.addLast("http2CodecSwapper", new Http2OrHttpHandler(new Http2StreamInitializer(ch, this::http1Handlers, http2MetricsChannelHandlers, connectionCloseHandler, connectionExpiryHandler), channelConfig, cp -> {
http1Codec(cp);
http1Handlers(cp);
}));
pipeline.addLast("codec_placeholder", DUMMY_HANDLER);
pipeline.addLast(swallowSomeHttp2ExceptionsHandler);
}
use of com.netflix.netty.common.Http2ConnectionCloseHandler in project zuul by Netflix.
the class Http2OrHttpHandlerTest method swapInHttp2HandlerBasedOnALPN.
@Test
public void swapInHttp2HandlerBasedOnALPN() throws Exception {
EmbeddedChannel channel = new EmbeddedChannel();
final NoopRegistry registry = new NoopRegistry();
final ChannelConfig channelConfig = new ChannelConfig();
channelConfig.add(new ChannelConfigValue<>(CommonChannelConfigKeys.maxHttp2HeaderListSize, 32768));
Http2ConnectionCloseHandler connectionCloseHandler = new Http2ConnectionCloseHandler(registry);
Http2ConnectionExpiryHandler connectionExpiryHandler = new Http2ConnectionExpiryHandler(100, 100, 20 * 60 * 1000);
Http2MetricsChannelHandlers http2MetricsChannelHandlers = new Http2MetricsChannelHandlers(registry, "server", "http2-443");
final Http2OrHttpHandler http2OrHttpHandler = new Http2OrHttpHandler(new Http2StreamInitializer(channel, (x) -> {
}, http2MetricsChannelHandlers, connectionCloseHandler, connectionExpiryHandler), channelConfig, cp -> {
});
channel.pipeline().addLast("codec_placeholder", new DummyChannelHandler());
channel.pipeline().addLast(Http2OrHttpHandler.class.getSimpleName(), http2OrHttpHandler);
http2OrHttpHandler.configurePipeline(channel.pipeline().lastContext(), ApplicationProtocolNames.HTTP_2);
assertThat(channel.pipeline().get(Http2FrameCodec.class.getSimpleName() + "#0")).isInstanceOf(Http2FrameCodec.class);
assertThat(channel.pipeline().get(BaseZuulChannelInitializer.HTTP_CODEC_HANDLER_NAME)).isInstanceOf(Http2MultiplexHandler.class);
assertEquals("HTTP/2", channel.attr(Http2OrHttpHandler.PROTOCOL_NAME).get());
}
Aggregations