use of com.webpieces.http2.api.dto.lowlevel.SettingsFrame in project webpieces by deanhiller.
the class RemoteSettingsManagement method applyRemoteSettings.
public void applyRemoteSettings(SettingsFrame settings) {
for (Http2Setting setting : settings.getSettings()) {
SettingsParameter key = setting.getKnownName();
if (key == null)
// TODO: forward unknown settings to clients
continue;
// unknown setting so skip it
apply(key, setting.getValue());
}
}
use of com.webpieces.http2.api.dto.lowlevel.SettingsFrame in project webpieces by deanhiller.
the class HeaderSettings method createSettingsFrame.
public static SettingsFrame createSettingsFrame(HeaderSettings localSettings) {
SettingsFrame f = new SettingsFrame();
if (localSettings.getHeaderTableSize() != DEFAULT.getHeaderTableSize())
f.addSetting(new Http2Setting(SettingsParameter.SETTINGS_HEADER_TABLE_SIZE, localSettings.getHeaderTableSize()));
if (localSettings.isPushEnabled() != DEFAULT.isPushEnabled()) {
long enabled = 1;
if (!localSettings.isPushEnabled())
enabled = 0;
f.addSetting(new Http2Setting(SettingsParameter.SETTINGS_ENABLE_PUSH, enabled));
}
if (localSettings.getMaxConcurrentStreams() != DEFAULT.getMaxConcurrentStreams())
f.addSetting(new Http2Setting(SettingsParameter.SETTINGS_MAX_CONCURRENT_STREAMS, localSettings.getMaxConcurrentStreams()));
if (localSettings.getInitialWindowSize() != DEFAULT.getInitialWindowSize())
f.addSetting(new Http2Setting(SettingsParameter.SETTINGS_INITIAL_WINDOW_SIZE, localSettings.getInitialWindowSize()));
if (localSettings.getMaxFrameSize() != DEFAULT.getMaxFrameSize())
f.addSetting(new Http2Setting(SettingsParameter.SETTINGS_MAX_FRAME_SIZE, localSettings.getMaxFrameSize()));
if (localSettings.getMaxHeaderListSize() != DEFAULT.getMaxHeaderListSize())
f.addSetting(new Http2Setting(SettingsParameter.SETTINGS_MAX_HEADER_LIST_SIZE, localSettings.getMaxHeaderListSize()));
return f;
}
use of com.webpieces.http2.api.dto.lowlevel.SettingsFrame 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.http2.api.dto.lowlevel.SettingsFrame in project webpieces by deanhiller.
the class TestHttp2Settings method testMarshalAck.
@Test
public void testMarshalAck() {
SettingsFrame frame = new SettingsFrame();
frame.setAck(true);
byte[] data = parser.marshal(frame).createByteArray();
String hexFrame = Util.toHexString(data);
Assert.assertEquals(ackFrame(), hexFrame);
}
use of com.webpieces.http2.api.dto.lowlevel.SettingsFrame in project webpieces by deanhiller.
the class TestS3InitialHttpConnections method testSection3_4WithH2cTokenPriorKnowledge.
/**
* Only will work with webpieces and 'jetty with alpn installed'
*
* should send PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n
* and server sends back it's preface...
* The server connection preface consists of a potentially empty SETTINGS
* frame (Section 6.5) that MUST be the first frame the server sends in the HTTP/2 connection.
*
* SettingsFrame{streamId=0, ack=false, settings=[{SETTINGS_HEADER_TABLE_SIZE: 4096}, {SETTINGS_MAX_CONCURRENT_STREAMS: 1024}, {SETTINGS_INITIAL_WINDOW_SIZE: 65535}, {SETTINGS_MAX_HEADER_LIST_SIZE: 8192}]}
* SettingsFrame{streamId=0, ack=true, settings=[]}
*/
@Test
public void testSection3_4WithH2cTokenPriorKnowledge() {
HeaderSettings settings = Http2Requests.createSomeSettings();
mockChannel.sendPrefaceAndSettings(HeaderSettings.createSettingsFrame(settings));
List<Http2Msg> frames = mockChannel.getFramesAndClear();
Assert.assertEquals(2, frames.size());
SettingsFrame serverSettings = (SettingsFrame) frames.get(0);
Assert.assertFalse(serverSettings.isAck());
SettingsFrame ackClientSettings = (SettingsFrame) frames.get(1);
Assert.assertTrue(ackClientSettings.isAck());
}
Aggregations