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;
}
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());
}
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;
}
Aggregations