Search in sources :

Example 1 with H2Setting

use of org.apache.hc.core5.http2.config.H2Setting in project httpcomponents-core by apache.

the class TestDefaultFrameFactory method testSettingFrame.

@Test
public void testSettingFrame() throws Exception {
    final FrameFactory frameFactory = new DefaultFrameFactory();
    final Frame<ByteBuffer> settingsFrame = frameFactory.createSettings(new H2Setting(H2Param.HEADER_TABLE_SIZE, 1024), new H2Setting(H2Param.MAX_CONCURRENT_STREAMS, 1));
    Assertions.assertEquals(FrameType.SETTINGS.value, settingsFrame.getType());
    Assertions.assertEquals(0, settingsFrame.getStreamId());
    Assertions.assertEquals(0, settingsFrame.getFlags());
    final ByteBuffer payload = settingsFrame.getPayload();
    Assertions.assertNotNull(payload);
    Assertions.assertEquals(12, payload.remaining());
}
Also used : H2Setting(org.apache.hc.core5.http2.config.H2Setting) ByteBuffer(java.nio.ByteBuffer) Test(org.junit.jupiter.api.Test)

Example 2 with H2Setting

use of org.apache.hc.core5.http2.config.H2Setting in project httpcomponents-core by apache.

the class TestH2Settings method testH2SettingBasics.

@Test
public void testH2SettingBasics() throws Exception {
    final H2Setting setting1 = new H2Setting(H2Param.ENABLE_PUSH, 0);
    final H2Setting setting2 = new H2Setting(H2Param.INITIAL_WINDOW_SIZE, 1024);
    Assertions.assertEquals("ENABLE_PUSH: 0", setting1.toString());
    Assertions.assertEquals("INITIAL_WINDOW_SIZE: 1024", setting2.toString());
}
Also used : H2Setting(org.apache.hc.core5.http2.config.H2Setting) Test(org.junit.jupiter.api.Test)

Example 3 with H2Setting

use of org.apache.hc.core5.http2.config.H2Setting in project httpcomponents-core by apache.

the class FrameFactory method createSettings.

public RawFrame createSettings(final H2Setting... settings) {
    final ByteBuffer payload = ByteBuffer.allocate(settings.length * 12);
    for (final H2Setting setting : settings) {
        payload.putShort((short) setting.getCode());
        payload.putInt(setting.getValue());
    }
    payload.flip();
    return new RawFrame(FrameType.SETTINGS.getValue(), 0, 0, payload);
}
Also used : H2Setting(org.apache.hc.core5.http2.config.H2Setting) ByteBuffer(java.nio.ByteBuffer)

Example 4 with H2Setting

use of org.apache.hc.core5.http2.config.H2Setting in project httpcomponents-core by apache.

the class AbstractH2StreamMultiplexer method onConnect.

public final void onConnect() throws HttpException, IOException {
    connState = ConnectionHandshake.ACTIVE;
    final RawFrame settingsFrame = frameFactory.createSettings(new H2Setting(H2Param.HEADER_TABLE_SIZE, localConfig.getHeaderTableSize()), new H2Setting(H2Param.ENABLE_PUSH, localConfig.isPushEnabled() ? 1 : 0), new H2Setting(H2Param.MAX_CONCURRENT_STREAMS, localConfig.getMaxConcurrentStreams()), new H2Setting(H2Param.INITIAL_WINDOW_SIZE, localConfig.getInitialWindowSize()), new H2Setting(H2Param.MAX_FRAME_SIZE, localConfig.getMaxFrameSize()), new H2Setting(H2Param.MAX_HEADER_LIST_SIZE, localConfig.getMaxHeaderListSize()));
    commitFrame(settingsFrame);
    localSettingState = SettingsHandshake.TRANSMITTED;
    maximizeConnWindow(connInputWindow.get());
    if (streamListener != null) {
        final int initInputWindow = connInputWindow.get();
        streamListener.onInputFlowControl(this, 0, initInputWindow, initInputWindow);
        final int initOutputWindow = connOutputWindow.get();
        streamListener.onOutputFlowControl(this, 0, initOutputWindow, initOutputWindow);
    }
}
Also used : H2Setting(org.apache.hc.core5.http2.config.H2Setting) RawFrame(org.apache.hc.core5.http2.frame.RawFrame)

Aggregations

H2Setting (org.apache.hc.core5.http2.config.H2Setting)4 ByteBuffer (java.nio.ByteBuffer)2 Test (org.junit.jupiter.api.Test)2 RawFrame (org.apache.hc.core5.http2.frame.RawFrame)1