Search in sources :

Example 6 with Http2Setting

use of com.webpieces.http2parser.api.dto.lib.Http2Setting in project webpieces by deanhiller.

the class SettingsMarshaller method marshalOut.

private DataWrapper marshalOut(List<Http2Setting> settings) {
    DataWrapper dataPayload;
    ByteBuffer payload = bufferPool.nextBuffer(6 * settings.size());
    for (Http2Setting setting : settings) {
        UnsignedData.putUnsignedShort(payload, setting.getId());
        UnsignedData.putUnsignedInt(payload, setting.getValue());
    }
    payload.flip();
    dataPayload = dataGen.wrapByteBuffer(payload);
    return dataPayload;
}
Also used : DataWrapper(org.webpieces.data.api.DataWrapper) Http2Setting(com.webpieces.http2parser.api.dto.lib.Http2Setting) ByteBuffer(java.nio.ByteBuffer)

Example 7 with Http2Setting

use of com.webpieces.http2parser.api.dto.lib.Http2Setting in project webpieces by deanhiller.

the class TestHttp2Settings method testParseSettings.

@Test
public void testParseSettings() {
    DataWrapper data = Util.hexToBytes(basicSettings());
    parser.parse(memento, data);
    SettingsFrame frame = (SettingsFrame) assertGood();
    Assert.assertEquals(0, frame.getStreamId());
    Assert.assertFalse(frame.isAck());
    Assert.assertEquals(frame.getSettings().size(), 2);
    Http2Setting setting = frame.getSettings().get(0);
    //first setting must be push from order in the bytes
    Assert.assertEquals(SettingsParameter.SETTINGS_ENABLE_PUSH, setting.getKnownName());
    Assert.assertEquals(1, setting.getValue());
}
Also used : DataWrapper(org.webpieces.data.api.DataWrapper) SettingsFrame(com.webpieces.http2parser.api.dto.SettingsFrame) Http2Setting(com.webpieces.http2parser.api.dto.lib.Http2Setting) Test(org.junit.Test)

Example 8 with Http2Setting

use of com.webpieces.http2parser.api.dto.lib.Http2Setting in project webpieces by deanhiller.

the class SettingsMarshaller method unmarshal.

private List<Http2Setting> unmarshal(ByteBuffer payloadByteBuffer) {
    List<Http2Setting> settings = new ArrayList<>();
    while (payloadByteBuffer.hasRemaining()) {
        int id = UnsignedData.getUnsignedShort(payloadByteBuffer);
        long value = UnsignedData.getUnsignedInt(payloadByteBuffer);
        Http2Setting http2Setting = new Http2Setting(id, value);
        settings.add(http2Setting);
        validate(http2Setting);
    }
    return settings;
}
Also used : Http2Setting(com.webpieces.http2parser.api.dto.lib.Http2Setting) ArrayList(java.util.ArrayList)

Aggregations

Http2Setting (com.webpieces.http2parser.api.dto.lib.Http2Setting)8 SettingsFrame (com.webpieces.http2parser.api.dto.SettingsFrame)5 DataWrapper (org.webpieces.data.api.DataWrapper)3 ByteBuffer (java.nio.ByteBuffer)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 ConnectionException (com.webpieces.http2parser.api.dto.error.ConnectionException)1 SettingsParameter (com.webpieces.http2parser.api.dto.lib.SettingsParameter)1 FrameHeaderData (com.webpieces.http2parser.impl.FrameHeaderData)1 List (java.util.List)1