use of io.vertx.core.http.Http2Settings in project vert.x by eclipse.
the class TestUtils method randomHttp2Settings.
/**
* Create random {@link Http2Settings} with valid values.
*
* @return the random settings
*/
public static Http2Settings randomHttp2Settings() {
long headerTableSize = 10 + randomPositiveInt() % (Http2CodecUtil.MAX_HEADER_TABLE_SIZE - 10);
boolean enablePush = randomBoolean();
long maxConcurrentStreams = 10 + randomPositiveLong() % (Http2CodecUtil.MAX_CONCURRENT_STREAMS - 10);
int initialWindowSize = 10 + randomPositiveInt() % (Http2CodecUtil.MAX_INITIAL_WINDOW_SIZE - 10);
int maxFrameSize = Http2CodecUtil.MAX_FRAME_SIZE_LOWER_BOUND + randomPositiveInt() % (Http2CodecUtil.MAX_FRAME_SIZE_UPPER_BOUND - Http2CodecUtil.MAX_FRAME_SIZE_LOWER_BOUND);
long maxHeaderListSize = 10 + randomPositiveLong() % (Http2CodecUtil.MAX_HEADER_LIST_SIZE - 10);
Http2Settings settings = new Http2Settings();
settings.setHeaderTableSize(headerTableSize);
settings.setPushEnabled(enablePush);
settings.setMaxConcurrentStreams(maxConcurrentStreams);
settings.setInitialWindowSize(initialWindowSize);
settings.setMaxFrameSize(maxFrameSize);
settings.setMaxHeaderListSize(maxHeaderListSize);
settings.set('\u0007', (randomPositiveLong() & 0xFFFFFFFFL));
return settings;
}
use of io.vertx.core.http.Http2Settings in project vert.x by eclipse.
the class Http2SettingsTest method toNettySettings.
@Test
public void toNettySettings() {
Http2Settings settings = new Http2Settings();
for (int i = 7; i <= 0xFFFF; i += 1) {
settings.set(0xFFFF, TestUtils.randomPositiveLong());
}
io.netty.handler.codec.http2.Http2Settings conv = HttpUtils.fromVertxSettings(settings);
for (int i = 1; i <= 0xFFFF; i += 1) {
assertEquals(settings.get(i), conv.get((char) i));
}
settings = HttpUtils.toVertxSettings(conv);
for (int i = 1; i <= 0xFFFF; i += 1) {
assertEquals(settings.get(i), conv.get((char) i));
}
}
use of io.vertx.core.http.Http2Settings in project vert.x by eclipse.
the class Http2Test method testResetClientRequestNotYetSent.
@Test
public void testResetClientRequestNotYetSent() throws Exception {
waitFor(2);
server.close();
server = vertx.createHttpServer(createBaseServerOptions().setInitialSettings(new Http2Settings().setMaxConcurrentStreams(1)));
AtomicInteger numReq = new AtomicInteger();
server.requestHandler(req -> {
assertEquals(0, numReq.getAndIncrement());
req.response().end();
complete();
});
startServer();
HttpClientRequest post = client.post(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, DEFAULT_TEST_URI, resp -> {
fail();
});
post.setChunked(true).write(TestUtils.randomBuffer(1024));
assertTrue(post.reset());
client.getNow(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, DEFAULT_TEST_URI, resp -> {
assertEquals(1, numReq.get());
complete();
});
await();
}
use of io.vertx.core.http.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.vertx.core.http.Http2Settings in project java-chassis by ServiceComb.
the class RestServerVerticle method createDefaultHttpServerOptions.
private HttpServerOptions createDefaultHttpServerOptions() {
HttpServerOptions serverOptions = new HttpServerOptions();
serverOptions.setIdleTimeout(TransportConfig.getConnectionIdleTimeoutInSeconds());
serverOptions.setCompressionSupported(TransportConfig.getCompressed());
serverOptions.setMaxHeaderSize(TransportConfig.getMaxHeaderSize());
serverOptions.setMaxFormAttributeSize(TransportConfig.getMaxFormAttributeSize());
serverOptions.setCompressionLevel(TransportConfig.getCompressionLevel());
serverOptions.setMaxChunkSize(TransportConfig.getMaxChunkSize());
serverOptions.setDecompressionSupported(TransportConfig.getDecompressionSupported());
serverOptions.setDecoderInitialBufferSize(TransportConfig.getDecoderInitialBufferSize());
serverOptions.setHttp2ConnectionWindowSize(TransportConfig.getHttp2ConnectionWindowSize());
serverOptions.setMaxInitialLineLength(TransportConfig.getMaxInitialLineLength());
if (endpointObject.isHttp2Enabled()) {
serverOptions.setUseAlpn(TransportConfig.getUseAlpn()).setInitialSettings(new Http2Settings().setPushEnabled(TransportConfig.getPushEnabled()).setMaxConcurrentStreams(TransportConfig.getMaxConcurrentStreams()).setHeaderTableSize(TransportConfig.getHttp2HeaderTableSize()).setInitialWindowSize(TransportConfig.getInitialWindowSize()).setMaxFrameSize(TransportConfig.getMaxFrameSize()).setMaxHeaderListSize(TransportConfig.getMaxHeaderListSize()));
}
if (endpointObject.isSslEnabled()) {
SSLOptionFactory factory = SSLOptionFactory.createSSLOptionFactory(SSL_KEY, null);
SSLOption sslOption;
if (factory == null) {
sslOption = SSLOption.buildFromYaml(SSL_KEY);
} else {
sslOption = factory.createSSLOption();
}
SSLCustom sslCustom = SSLCustom.createSSLCustom(sslOption.getSslCustomClass());
VertxTLSBuilder.buildNetServerOptions(sslOption, sslCustom, serverOptions);
}
return serverOptions;
}
Aggregations