use of io.netty.handler.codec.http2.Http2SettingsFrame in project netty by netty.
the class Http2MultiplexTest method setUp.
@BeforeEach
public void setUp() {
childChannelInitializer = new TestChannelInitializer();
parentChannel = new EmbeddedChannel();
frameInboundWriter = new Http2FrameInboundWriter(parentChannel);
parentChannel.connect(new InetSocketAddress(0));
frameWriter = Http2TestUtil.mockedFrameWriter();
codec = newCodec(childChannelInitializer, frameWriter);
parentChannel.pipeline().addLast(codec);
ChannelHandler multiplexer = newMultiplexer(childChannelInitializer);
if (multiplexer != null) {
parentChannel.pipeline().addLast(multiplexer);
}
parentChannel.runPendingTasks();
parentChannel.pipeline().fireChannelActive();
parentChannel.writeInbound(Http2CodecUtil.connectionPrefaceBuf());
Http2Settings settings = new Http2Settings().initialWindowSize(initialRemoteStreamWindow);
frameInboundWriter.writeInboundSettings(settings);
verify(frameWriter).writeSettingsAck(eqCodecCtx(), anyChannelPromise());
frameInboundWriter.writeInboundSettingsAck();
Http2SettingsFrame settingsFrame = parentChannel.readInbound();
assertNotNull(settingsFrame);
Http2SettingsAckFrame settingsAckFrame = parentChannel.readInbound();
assertNotNull(settingsAckFrame);
// Handshake
verify(frameWriter).writeSettings(eqCodecCtx(), anyHttp2Settings(), anyChannelPromise());
}
use of io.netty.handler.codec.http2.Http2SettingsFrame in project netty by netty.
the class Http2FrameCodecTest method receiveSettings.
@Test
public void receiveSettings() throws Http2Exception {
Http2Settings settings = new Http2Settings().maxConcurrentStreams(1);
frameInboundWriter.writeInboundSettings(settings);
Http2SettingsFrame settingsFrame = inboundHandler.readInbound();
assertNotNull(settingsFrame);
assertEquals(settings, settingsFrame.settings());
}
use of io.netty.handler.codec.http2.Http2SettingsFrame in project aws-sdk-java-v2 by aws.
the class WindowSizeTest method execute_noExplicitValueSet_sendsDefaultValueInSettings.
@Test
public void execute_noExplicitValueSet_sendsDefaultValueInSettings() throws InterruptedException {
ConcurrentLinkedQueue<Http2Frame> receivedFrames = new ConcurrentLinkedQueue<>();
server = new TestH2Server(() -> new StreamHandler(receivedFrames));
server.init();
netty = NettyNioAsyncHttpClient.builder().protocol(Protocol.HTTP2).build();
AsyncExecuteRequest req = AsyncExecuteRequest.builder().requestContentPublisher(new EmptyPublisher()).request(SdkHttpFullRequest.builder().method(SdkHttpMethod.GET).protocol("http").host("localhost").port(server.port()).build()).responseHandler(new SdkAsyncHttpResponseHandler() {
@Override
public void onHeaders(SdkHttpResponse headers) {
}
@Override
public void onStream(Publisher<ByteBuffer> stream) {
}
@Override
public void onError(Throwable error) {
}
}).build();
netty.execute(req).join();
List<Http2Settings> receivedSettings = receivedFrames.stream().filter(f -> f instanceof Http2SettingsFrame).map(f -> (Http2SettingsFrame) f).map(Http2SettingsFrame::settings).collect(Collectors.toList());
assertThat(receivedSettings.size()).isGreaterThan(0);
for (Http2Settings s : receivedSettings) {
assertThat(s.initialWindowSize()).isEqualTo(DEFAULT_INIT_WINDOW_SIZE);
}
}
use of io.netty.handler.codec.http2.Http2SettingsFrame in project aws-sdk-java-v2 by aws.
the class WindowSizeTest method expectCorrectWindowSizeValueTest.
private void expectCorrectWindowSizeValueTest(Integer builderSetterValue, int settingsFrameValue) throws InterruptedException {
ConcurrentLinkedQueue<Http2Frame> receivedFrames = new ConcurrentLinkedQueue<>();
server = new TestH2Server(() -> new StreamHandler(receivedFrames));
server.init();
netty = NettyNioAsyncHttpClient.builder().protocol(Protocol.HTTP2).http2Configuration(Http2Configuration.builder().initialWindowSize(builderSetterValue).build()).build();
AsyncExecuteRequest req = AsyncExecuteRequest.builder().requestContentPublisher(new EmptyPublisher()).request(SdkHttpFullRequest.builder().method(SdkHttpMethod.GET).protocol("http").host("localhost").port(server.port()).build()).responseHandler(new SdkAsyncHttpResponseHandler() {
@Override
public void onHeaders(SdkHttpResponse headers) {
}
@Override
public void onStream(Publisher<ByteBuffer> stream) {
}
@Override
public void onError(Throwable error) {
}
}).build();
netty.execute(req).join();
List<Http2Settings> receivedSettings = receivedFrames.stream().filter(f -> f instanceof Http2SettingsFrame).map(f -> (Http2SettingsFrame) f).map(Http2SettingsFrame::settings).collect(Collectors.toList());
assertThat(receivedSettings.size()).isGreaterThan(0);
for (Http2Settings s : receivedSettings) {
assertThat(s.initialWindowSize()).isEqualTo(settingsFrameValue);
}
}
use of io.netty.handler.codec.http2.Http2SettingsFrame in project aws-sdk-java-v2 by aws.
the class Http2SettingsFrameHandlerTest method http2SettingsFrame.
private Http2SettingsFrame http2SettingsFrame(long serverMaxStreams) {
return new Http2SettingsFrame() {
@Override
public Http2Settings settings() {
Http2Settings http2Settings = new Http2Settings();
http2Settings.maxConcurrentStreams(serverMaxStreams);
return http2Settings;
}
@Override
public String name() {
return "test";
}
};
}
Aggregations