use of com.webpieces.http2parser.api.dto.SettingsFrame in project webpieces by deanhiller.
the class TestHttp2Settings method testMarshalSettings.
@Test
public void testMarshalSettings() {
SettingsFrame frame = new SettingsFrame();
frame.addSetting(new Http2Setting(SettingsParameter.SETTINGS_ENABLE_PUSH, 1L));
frame.addSetting(new Http2Setting(SettingsParameter.SETTINGS_MAX_CONCURRENT_STREAMS, 256L));
byte[] data = parser.marshal(frame).createByteArray();
String hexFrame = Util.toHexString(data);
Assert.assertEquals(basicSettings(), hexFrame);
}
use of com.webpieces.http2parser.api.dto.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());
}
use of com.webpieces.http2parser.api.dto.SettingsFrame in project webpieces by deanhiller.
the class TestSMaxConcurrentSetting method testSend2ndPushHeadersOnlyOnAfterSettingsFrameMaxConcurrentBigger.
@Test
public void testSend2ndPushHeadersOnlyOnAfterSettingsFrameMaxConcurrentBigger() throws InterruptedException, ExecutionException, TimeoutException {
WriterHolder sent = sendTwoRequests();
//client increases max concurrent
HeaderSettings settings = new HeaderSettings();
settings.setMaxConcurrentStreams(2L);
mockChannel.send(HeaderSettings.createSettingsFrame(settings));
List<Http2Msg> frames = mockChannel.getFramesAndClear();
Assert.assertEquals(2, frames.size());
Assert.assertEquals(sent.getResp2(), frames.get(0));
SettingsFrame dataRecv1 = (SettingsFrame) frames.get(1);
Assert.assertTrue(dataRecv1.isAck());
StreamWriter writer2 = sent.getFuture2().get(2, TimeUnit.SECONDS);
DataFrame data2 = Http2Requests.createData1(sent.getResp2().getStreamId(), true);
writer2.processPiece(data2);
DataFrame dataRecv2 = (DataFrame) mockChannel.getFrameAndClear();
Assert.assertEquals(sent.getResp2().getStreamId(), dataRecv2.getStreamId());
}
use of com.webpieces.http2parser.api.dto.SettingsFrame in project webpieces by deanhiller.
the class TestC3InitialHttpConnections 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() {
//verify settings on connect were sent
List<Http2Msg> frames = mockChannel.getFramesAndClear();
Preface preface = (Preface) frames.get(0);
preface.verify();
Http2Msg settings1 = frames.get(1);
Assert.assertEquals(HeaderSettings.createSettingsFrame(localSettings), settings1);
//server's settings frame is finally coming in as well with maxConcurrent=1
HeaderSettings settings = new HeaderSettings();
settings.setMaxConcurrentStreams(1L);
mockChannel.write(HeaderSettings.createSettingsFrame(settings));
//ack client frame
mockChannel.write(new SettingsFrame(true));
SettingsFrame clientAck = (SettingsFrame) mockChannel.getFrameAndClear();
Assert.assertEquals(true, clientAck.isAck());
}
use of com.webpieces.http2parser.api.dto.SettingsFrame in project webpieces by deanhiller.
the class TestCMaxConcurrentSetting method testSend2ndRequestOnlyOnAfterSettingsFrameMaxConcurrentBigger.
@Test
public void testSend2ndRequestOnlyOnAfterSettingsFrameMaxConcurrentBigger() throws InterruptedException, ExecutionException {
RequestsSent sent = sendTwoRequests();
Assert.assertFalse(sent.getRequest2().getFuture().isDone());
//server's settings frame is finally coming in as well with maxConcurrent=1
HeaderSettings settings = new HeaderSettings();
settings.setMaxConcurrentStreams(2L);
mockChannel.write(HeaderSettings.createSettingsFrame(settings));
//ack client frame
mockChannel.write(new SettingsFrame(true));
List<Http2Msg> msgs = mockChannel.getFramesAndClear();
Assert.assertEquals(sent.getRequest2().getRequest(), msgs.get(0));
Assert.assertTrue(sent.getRequest2().getFuture().isDone());
SettingsFrame ack = (SettingsFrame) msgs.get(1);
Assert.assertEquals(true, ack.isAck());
}
Aggregations