Search in sources :

Example 6 with Http2Settings

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

Example 7 with Http2Settings

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

Example 8 with Http2Settings

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

Example 9 with Http2Settings

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

Example 10 with Http2Settings

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;
}
Also used : SSLOptionFactory(org.apache.servicecomb.foundation.ssl.SSLOptionFactory) HttpServerOptions(io.vertx.core.http.HttpServerOptions) Http2Settings(io.vertx.core.http.Http2Settings) SSLOption(org.apache.servicecomb.foundation.ssl.SSLOption) SSLCustom(org.apache.servicecomb.foundation.ssl.SSLCustom)

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