Search in sources :

Example 1 with Http2Settings

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);
}
Also used : Http2Settings(io.vertx.core.http.Http2Settings) TestUtils.assertIllegalArgumentException(io.vertx.test.core.TestUtils.assertIllegalArgumentException) Test(org.junit.Test)

Example 2 with Http2Settings

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());
}
Also used : HashMap(java.util.HashMap) Http2Settings(io.vertx.core.http.Http2Settings) Test(org.junit.Test)

Example 3 with Http2Settings

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);
}
Also used : Http2Settings(io.vertx.core.http.Http2Settings) TestUtils.assertIllegalArgumentException(io.vertx.test.core.TestUtils.assertIllegalArgumentException) Test(org.junit.Test)

Example 4 with Http2Settings

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;
}
Also used : io.netty.handler.codec.http(io.netty.handler.codec.http) Http2Settings(io.vertx.core.http.Http2Settings) Http2Settings(io.vertx.core.http.Http2Settings) Http2Settings(io.netty.handler.codec.http2.Http2Settings)

Example 5 with Http2Settings

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;
}
Also used : Buffer(io.vertx.core.buffer.Buffer) Http2Settings(io.vertx.core.http.Http2Settings) Http2Settings(io.netty.handler.codec.http2.Http2Settings) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

Http2Settings (io.vertx.core.http.Http2Settings)10 Test (org.junit.Test)5 Http2Settings (io.netty.handler.codec.http2.Http2Settings)3 TestUtils.assertIllegalArgumentException (io.vertx.test.core.TestUtils.assertIllegalArgumentException)2 io.netty.handler.codec.http (io.netty.handler.codec.http)1 Buffer (io.vertx.core.buffer.Buffer)1 HttpClientRequest (io.vertx.core.http.HttpClientRequest)1 HttpServerOptions (io.vertx.core.http.HttpServerOptions)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 HashMap (java.util.HashMap)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 SSLCustom (org.apache.servicecomb.foundation.ssl.SSLCustom)1 SSLOption (org.apache.servicecomb.foundation.ssl.SSLOption)1 SSLOptionFactory (org.apache.servicecomb.foundation.ssl.SSLOptionFactory)1