use of io.netty.handler.codec.http2.Http2MultiplexHandler in project reactor-netty by reactor.
the class HttpClientConfig method configureHttp2Pipeline.
static void configureHttp2Pipeline(ChannelPipeline p, boolean acceptGzip, HttpResponseDecoderSpec decoder, Http2Settings http2Settings, ConnectionObserver observer) {
Http2FrameCodecBuilder http2FrameCodecBuilder = Http2FrameCodecBuilder.forClient().validateHeaders(decoder.validateHeaders()).initialSettings(http2Settings);
if (p.get(NettyPipeline.LoggingHandler) != null) {
http2FrameCodecBuilder.frameLogger(new Http2FrameLogger(LogLevel.DEBUG, "reactor.netty.http.client.h2"));
}
p.addBefore(NettyPipeline.ReactiveBridge, NettyPipeline.HttpCodec, http2FrameCodecBuilder.build()).addBefore(NettyPipeline.ReactiveBridge, NettyPipeline.H2MultiplexHandler, new Http2MultiplexHandler(new H2Codec(acceptGzip))).addBefore(NettyPipeline.ReactiveBridge, NettyPipeline.HttpTrafficHandler, new HttpTrafficHandler(observer));
}
use of io.netty.handler.codec.http2.Http2MultiplexHandler in project reactor-netty by reactor.
the class Http2PoolTest method acquireRelease.
@Test
void acquireRelease() {
EmbeddedChannel channel = new EmbeddedChannel(Http2FrameCodecBuilder.forClient().build(), new Http2MultiplexHandler(new ChannelHandlerAdapter() {
}));
PoolBuilder<Connection, PoolConfig<Connection>> poolBuilder = PoolBuilder.from(Mono.just(Connection.from(channel))).idleResourceReuseLruOrder().maxPendingAcquireUnbounded().sizeBetween(0, 1);
InstrumentedPool<Connection> http2Pool = poolBuilder.build(config -> new Http2Pool(config, -1));
try {
List<PooledRef<Connection>> acquired = new ArrayList<>();
http2Pool.acquire().subscribe(acquired::add);
http2Pool.acquire().subscribe(acquired::add);
http2Pool.acquire().subscribe(acquired::add);
assertThat(acquired).hasSize(3);
assertThat(http2Pool.metrics().acquiredSize()).isEqualTo(3);
for (PooledRef<Connection> slot : acquired) {
slot.release().block(Duration.ofSeconds(1));
}
assertThat(http2Pool.metrics().acquiredSize()).isEqualTo(0);
for (PooledRef<Connection> slot : acquired) {
// second release() should be ignored and ACQUIRED size should remain the same
slot.release().block(Duration.ofSeconds(1));
}
assertThat(http2Pool.metrics().acquiredSize()).isEqualTo(0);
} finally {
channel.finishAndReleaseAll();
Connection.from(channel).dispose();
}
}
Aggregations