use of io.vertx.core.http.Http2Settings in project vert.x by eclipse.
the class Http2SettingsTest method testSettinsMax.
@Test
public void testSettinsMax() {
for (int i = 1; i <= 6; i++) {
try {
new Http2Settings().set(i, max[i - 1] + 1);
fail("Was expecting setting " + (i - 1) + " update to throw IllegalArgumentException");
} catch (IllegalArgumentException ignore) {
}
}
Http2Settings settings = new Http2Settings();
for (int i = 1; i <= 6; i++) {
settings.set(i, max[i - 1]);
}
HttpUtils.fromVertxSettings(settings);
}
use of io.vertx.core.http.Http2Settings in project vert.x by eclipse.
the class Http2SettingsTest method testSettings.
@Test
public void testSettings() {
Http2Settings settings = new Http2Settings();
assertEquals(true, settings.isPushEnabled());
assertEquals(Http2Settings.DEFAULT_MAX_HEADER_LIST_SIZE, settings.getMaxHeaderListSize());
assertEquals(Http2Settings.DEFAULT_MAX_CONCURRENT_STREAMS, settings.getMaxConcurrentStreams());
assertEquals(Http2Settings.DEFAULT_INITIAL_WINDOW_SIZE, settings.getInitialWindowSize());
assertEquals(Http2Settings.DEFAULT_MAX_FRAME_SIZE, settings.getMaxFrameSize());
assertEquals(null, settings.getExtraSettings());
Http2Settings update = TestUtils.randomHttp2Settings();
assertFalse(settings.equals(update));
assertNotSame(settings.hashCode(), settings.hashCode());
assertSame(settings, settings.setHeaderTableSize(update.getHeaderTableSize()));
assertEquals(settings.getHeaderTableSize(), update.getHeaderTableSize());
assertSame(settings, settings.setPushEnabled(update.isPushEnabled()));
assertEquals(settings.isPushEnabled(), update.isPushEnabled());
assertSame(settings, settings.setMaxHeaderListSize(update.getMaxHeaderListSize()));
assertEquals(settings.getMaxHeaderListSize(), update.getMaxHeaderListSize());
assertSame(settings, settings.setMaxConcurrentStreams(update.getMaxConcurrentStreams()));
assertEquals(settings.getMaxConcurrentStreams(), update.getMaxConcurrentStreams());
assertSame(settings, settings.setInitialWindowSize(update.getInitialWindowSize()));
assertEquals(settings.getInitialWindowSize(), update.getInitialWindowSize());
assertSame(settings, settings.setMaxFrameSize(update.getMaxFrameSize()));
assertEquals(settings.getMaxFrameSize(), update.getMaxFrameSize());
assertSame(settings, settings.setExtraSettings(update.getExtraSettings()));
Map<Integer, Long> extraSettings = new HashMap<>(update.getExtraSettings());
assertEquals(update.getExtraSettings(), extraSettings);
extraSettings.clear();
assertEquals(update.getExtraSettings(), settings.getExtraSettings());
assertTrue(settings.equals(update));
assertEquals(settings.hashCode(), settings.hashCode());
settings = new Http2Settings(update);
assertEquals(settings.getHeaderTableSize(), update.getHeaderTableSize());
assertEquals(settings.isPushEnabled(), update.isPushEnabled());
assertEquals(settings.getMaxHeaderListSize(), update.getMaxHeaderListSize());
assertEquals(settings.getMaxConcurrentStreams(), update.getMaxConcurrentStreams());
assertEquals(settings.getInitialWindowSize(), update.getInitialWindowSize());
assertEquals(settings.getMaxFrameSize(), update.getMaxFrameSize());
assertEquals(update.getExtraSettings(), settings.getExtraSettings());
}
use of io.vertx.core.http.Http2Settings in project vert.x by eclipse.
the class Http2SettingsTest method testSettingsMin.
@Test
public void testSettingsMin() {
for (int i = 1; i <= 6; i++) {
try {
new Http2Settings().set(i, min[i - 1] - 1);
fail();
} catch (IllegalArgumentException ignore) {
}
}
Http2Settings settings = new Http2Settings();
for (int i = 1; i <= 6; i++) {
settings.set(i, min[i - 1]);
}
HttpUtils.fromVertxSettings(settings);
}
use of io.vertx.core.http.Http2Settings in project vert.x by eclipse.
the class HttpUtils method toVertxSettings.
public static io.vertx.core.http.Http2Settings toVertxSettings(Http2Settings settings) {
io.vertx.core.http.Http2Settings converted = new io.vertx.core.http.Http2Settings();
Boolean pushEnabled = settings.pushEnabled();
if (pushEnabled != null) {
converted.setPushEnabled(pushEnabled);
}
Long maxConcurrentStreams = settings.maxConcurrentStreams();
if (maxConcurrentStreams != null) {
converted.setMaxConcurrentStreams(maxConcurrentStreams);
}
Long maxHeaderListSize = settings.maxHeaderListSize();
if (maxHeaderListSize != null) {
converted.setMaxHeaderListSize(maxHeaderListSize);
}
Integer maxFrameSize = settings.maxFrameSize();
if (maxFrameSize != null) {
converted.setMaxFrameSize(maxFrameSize);
}
Integer initialWindowSize = settings.initialWindowSize();
if (initialWindowSize != null) {
converted.setInitialWindowSize(initialWindowSize);
}
Long headerTableSize = settings.headerTableSize();
if (headerTableSize != null) {
converted.setHeaderTableSize(headerTableSize);
}
settings.forEach((key, value) -> {
if (key > 6) {
converted.set(key, value);
}
});
return converted;
}
use of io.vertx.core.http.Http2Settings in project vert.x by eclipse.
the class HttpUtils method decodeSettings.
static Http2Settings decodeSettings(String base64Settings) {
try {
Http2Settings settings = new Http2Settings();
Buffer buffer = Buffer.buffer(Base64.getUrlDecoder().decode(base64Settings));
int pos = 0;
int len = buffer.length();
while (pos < len) {
int i = buffer.getUnsignedShort(pos);
pos += 2;
long j = buffer.getUnsignedInt(pos);
pos += 4;
settings.put((char) i, (Long) j);
}
return settings;
} catch (Exception ignore) {
}
return null;
}
Aggregations