use of io.netty.handler.codec.http2.Http2Settings in project grpc-java by grpc.
the class NettyClientHandlerTest method receiveMaxConcurrentStreams.
private void receiveMaxConcurrentStreams(int max) throws Exception {
ByteBuf serializedSettings = serializeSettings(new Http2Settings().maxConcurrentStreams(max));
channelRead(serializedSettings);
}
use of io.netty.handler.codec.http2.Http2Settings in project vert.x by eclipse.
the class Http2ServerTest method testServerInitialSettings.
@Test
public void testServerInitialSettings() throws Exception {
io.vertx.core.http.Http2Settings settings = TestUtils.randomHttp2Settings();
server.close();
server = vertx.createHttpServer(serverOptions.setInitialSettings(settings));
server.requestHandler(req -> fail());
startServer();
TestClient client = new TestClient();
ChannelFuture fut = client.connect(DEFAULT_HTTPS_PORT, DEFAULT_HTTPS_HOST, request -> {
request.decoder.frameListener(new Http2FrameAdapter() {
@Override
public void onSettingsRead(ChannelHandlerContext ctx, Http2Settings newSettings) throws Http2Exception {
vertx.runOnContext(v -> {
assertEquals((Long) settings.getHeaderTableSize(), newSettings.headerTableSize());
assertEquals((Long) settings.getMaxConcurrentStreams(), newSettings.maxConcurrentStreams());
assertEquals((Integer) settings.getInitialWindowSize(), newSettings.initialWindowSize());
assertEquals((Integer) settings.getMaxFrameSize(), newSettings.maxFrameSize());
assertEquals((Long) settings.getMaxHeaderListSize(), newSettings.maxHeaderListSize());
assertEquals(settings.get(''), newSettings.get(''));
testComplete();
});
}
});
});
fut.sync();
await();
}
use of io.netty.handler.codec.http2.Http2Settings in project vert.x by eclipse.
the class HttpUtils method fromVertxSettings.
public static Http2Settings fromVertxSettings(io.vertx.core.http.Http2Settings settings) {
Http2Settings converted = new Http2Settings();
converted.pushEnabled(settings.isPushEnabled());
converted.maxFrameSize(settings.getMaxFrameSize());
converted.initialWindowSize(settings.getInitialWindowSize());
converted.headerTableSize(settings.getHeaderTableSize());
converted.maxConcurrentStreams(settings.getMaxConcurrentStreams());
converted.maxHeaderListSize(settings.getMaxHeaderListSize());
if (settings.getExtraSettings() != null) {
settings.getExtraSettings().forEach((key, value) -> {
converted.put((char) (int) key, value);
});
}
return converted;
}
use of io.netty.handler.codec.http2.Http2Settings in project vert.x by eclipse.
the class VertxHttp2ClientUpgradeCodec method setUpgradeHeaders.
@Override
public Collection<CharSequence> setUpgradeHeaders(ChannelHandlerContext ctx, HttpRequest upgradeRequest) {
Http2Settings nettySettings = new Http2Settings();
HttpUtils.fromVertxInitialSettings(false, settings, nettySettings);
Buffer buf = Buffer.buffer();
for (CharObjectMap.PrimitiveEntry<Long> entry : nettySettings.entries()) {
buf.appendUnsignedShort(entry.key());
buf.appendUnsignedInt(entry.value());
}
String encodedSettings = new String(java.util.Base64.getUrlEncoder().encode(buf.getBytes()), UTF_8);
upgradeRequest.headers().set(HTTP_UPGRADE_SETTINGS_HEADER, encodedSettings);
return UPGRADE_HEADERS;
}
use of io.netty.handler.codec.http2.Http2Settings in project vert.x by eclipse.
the class Http2ConnectionBase method updateSettings.
@Override
public HttpConnection updateSettings(io.vertx.core.http.Http2Settings settings, @Nullable Handler<AsyncResult<Void>> completionHandler) {
Http2Settings settingsUpdate = HttpUtils.fromVertxSettings(settings);
updateSettings(settingsUpdate, completionHandler);
return this;
}
Aggregations