Example usage for io.netty.handler.codec.http2 Http2Settings initialWindowSize

List of usage examples for io.netty.handler.codec.http2 Http2Settings initialWindowSize

Introduction

In this page you can find the example usage for io.netty.handler.codec.http2 Http2Settings initialWindowSize.

Prototype

public Integer initialWindowSize() 

Source Link

Document

Gets the SETTINGS_INITIAL_WINDOW_SIZE value.

Usage

From source file:io.grpc.netty.AbstractNettyHandler.java

License:Apache License

AbstractNettyHandler(ChannelPromise channelUnused, Http2ConnectionDecoder decoder,
        Http2ConnectionEncoder encoder, Http2Settings initialSettings) {
    super(channelUnused, decoder, encoder, initialSettings);

    // During a graceful shutdown, wait until all streams are closed.
    gracefulShutdownTimeoutMillis(GRACEFUL_SHUTDOWN_NO_TIMEOUT);

    // Extract the connection window from the settings if it was set.
    this.initialConnectionWindow = initialSettings.initialWindowSize() == null ? -1
            : initialSettings.initialWindowSize();
}

From source file:io.vertx.core.http.Http2ServerTest.java

License:Open Source License

@Test
public void testServerInitialSettings() throws Exception {
    io.vertx.core.http.Http2Settings settings = TestUtils.randomHttp2Settings();
    server.close();/*from   w  w  w  .ja v a  2s  . c om*/
    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('\u0007'), newSettings.get('\u0007'));
                    testComplete();
                });
            }
        });
    });
    fut.sync();
    await();
}

From source file:io.vertx.core.http.Http2ServerTest.java

License:Open Source License

@Test
public void testServerSettings() throws Exception {
    waitFor(2);//from w  ww  . j av  a  2s. co  m
    io.vertx.core.http.Http2Settings expectedSettings = TestUtils.randomHttp2Settings();
    expectedSettings.setHeaderTableSize((int) io.vertx.core.http.Http2Settings.DEFAULT_HEADER_TABLE_SIZE);
    Context otherContext = vertx.getOrCreateContext();
    server.connectionHandler(conn -> {
        Context ctx = Vertx.currentContext();
        otherContext.runOnContext(v -> {
            conn.updateSettings(expectedSettings, ar -> {
                assertSame(ctx, Vertx.currentContext());
                io.vertx.core.http.Http2Settings ackedSettings = conn.settings();
                assertEquals(expectedSettings.getMaxHeaderListSize(), ackedSettings.getMaxHeaderListSize());
                assertEquals(expectedSettings.getMaxFrameSize(), ackedSettings.getMaxFrameSize());
                assertEquals(expectedSettings.getInitialWindowSize(), ackedSettings.getInitialWindowSize());
                assertEquals(expectedSettings.getMaxConcurrentStreams(),
                        ackedSettings.getMaxConcurrentStreams());
                assertEquals(expectedSettings.getHeaderTableSize(), ackedSettings.getHeaderTableSize());
                assertEquals(expectedSettings.get('\u0007'), ackedSettings.get(7));
                complete();
            });
        });
    });
    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() {
            AtomicInteger count = new AtomicInteger();
            Context context = vertx.getOrCreateContext();

            @Override
            public void onSettingsRead(ChannelHandlerContext ctx, Http2Settings newSettings)
                    throws Http2Exception {
                context.runOnContext(v -> {
                    switch (count.getAndIncrement()) {
                    case 0:
                        // Initial settings
                        break;
                    case 1:
                        // Server sent settings
                        assertEquals((Long) expectedSettings.getMaxHeaderListSize(),
                                newSettings.maxHeaderListSize());
                        assertEquals((Integer) expectedSettings.getMaxFrameSize(), newSettings.maxFrameSize());
                        assertEquals((Integer) expectedSettings.getInitialWindowSize(),
                                newSettings.initialWindowSize());
                        assertEquals((Long) expectedSettings.getMaxConcurrentStreams(),
                                newSettings.maxConcurrentStreams());
                        assertEquals(null, newSettings.headerTableSize());
                        complete();
                        break;
                    default:
                        fail();
                    }
                });
            }
        });
    });
    fut.sync();
    await();
}

From source file:io.vertx.core.http.impl.HttpUtils.java

License:Open Source License

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);
    }//w  ww.  j a v  a  2 s  . c om
    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;
}

From source file:io.vertx.test.core.Http2ServerTest.java

License:Open Source License

@Test
public void testServerSettings() throws Exception {
    waitFor(2);/* w ww .ja va  2 s .  c  o  m*/
    io.vertx.core.http.Http2Settings expectedSettings = TestUtils.randomHttp2Settings();
    expectedSettings.setHeaderTableSize((int) io.vertx.core.http.Http2Settings.DEFAULT_HEADER_TABLE_SIZE);
    server.close();
    server = vertx.createHttpServer(serverOptions);
    Context otherContext = vertx.getOrCreateContext();
    server.connectionHandler(conn -> {
        otherContext.runOnContext(v -> {
            conn.updateSettings(expectedSettings, ar -> {
                assertSame(otherContext, Vertx.currentContext());
                io.vertx.core.http.Http2Settings ackedSettings = conn.settings();
                assertEquals(expectedSettings.getMaxHeaderListSize(), ackedSettings.getMaxHeaderListSize());
                assertEquals(expectedSettings.getMaxFrameSize(), ackedSettings.getMaxFrameSize());
                assertEquals(expectedSettings.getInitialWindowSize(), ackedSettings.getInitialWindowSize());
                assertEquals(expectedSettings.getMaxConcurrentStreams(),
                        ackedSettings.getMaxConcurrentStreams());
                assertEquals(expectedSettings.getHeaderTableSize(), ackedSettings.getHeaderTableSize());
                assertEquals(expectedSettings.get('\u0007'), ackedSettings.get(7));
                complete();
            });
        });
    });
    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() {
            AtomicInteger count = new AtomicInteger();

            @Override
            public void onSettingsRead(ChannelHandlerContext ctx, Http2Settings newSettings)
                    throws Http2Exception {
                vertx.runOnContext(v -> {
                    switch (count.getAndIncrement()) {
                    case 0:
                        // Initial settings
                        break;
                    case 1:
                        // Server sent settings
                        assertEquals((Long) expectedSettings.getMaxHeaderListSize(),
                                newSettings.maxHeaderListSize());
                        assertEquals((Integer) expectedSettings.getMaxFrameSize(), newSettings.maxFrameSize());
                        assertEquals((Integer) expectedSettings.getInitialWindowSize(),
                                newSettings.initialWindowSize());
                        assertEquals((Long) expectedSettings.getMaxConcurrentStreams(),
                                newSettings.maxConcurrentStreams());
                        assertEquals(null, newSettings.headerTableSize());
                        complete();
                        break;
                    default:
                        fail();
                    }
                });
            }
        });
    });
    fut.sync();
    await();
}