use of com.webpieces.http2.api.dto.lowlevel.lib.Http2Setting in project webpieces by deanhiller.
the class SettingsMarshaller method validate.
private void validate(Http2Setting http2Setting) {
SettingsParameter key = SettingsParameter.lookup(http2Setting.getId());
long value = http2Setting.getValue();
if (key == null)
// unknown setting
return;
switch(key) {
case SETTINGS_ENABLE_PUSH:
if (value != 0 && value != 1)
throw new ConnectionException(CancelReasonCode.INVALID_SETTING, 0, "push setting must be 0 or 1 but was=" + value);
break;
case SETTINGS_INITIAL_WINDOW_SIZE:
validateWindowSize(value);
break;
case SETTINGS_MAX_FRAME_SIZE:
validateMaxFrameSize(value);
break;
case SETTINGS_HEADER_TABLE_SIZE:
case SETTINGS_MAX_CONCURRENT_STREAMS:
case SETTINGS_MAX_HEADER_LIST_SIZE:
break;
default:
throw new IllegalArgumentException("case statement missing new setting=" + key + " with value=" + value);
}
}
use of com.webpieces.http2.api.dto.lowlevel.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;
}
use of com.webpieces.http2.api.dto.lowlevel.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 = DATA_GEN.wrapByteBuffer(payload);
return dataPayload;
}
use of com.webpieces.http2.api.dto.lowlevel.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());
}
Aggregations