Search in sources :

Example 6 with HeaderSettings

use of com.webpieces.http2engine.impl.shared.data.HeaderSettings 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());
}
Also used : SettingsFrame(com.webpieces.http2parser.api.dto.SettingsFrame) HeaderSettings(com.webpieces.http2engine.impl.shared.data.HeaderSettings) Preface(org.webpieces.http2client.mock.Preface) Http2Msg(com.webpieces.http2parser.api.dto.lib.Http2Msg) Test(org.junit.Test)

Example 7 with HeaderSettings

use of com.webpieces.http2engine.impl.shared.data.HeaderSettings in project webpieces by deanhiller.

the class TestC6_5SettingsFrameErrors method testSection6_5AckNonEmptyPayload.

@Test
public void testSection6_5AckNonEmptyPayload() {
    //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));
    //clear the ack frame 
    mockChannel.getFrameAndClear();
    String badAckFrame = // length
    "00 00 01" + // type
    "04" + // flags (ack)
    "01" + // R + streamid
    "00 00 00 00" + //payload 
    "00";
    //ack client frame
    mockChannel.writeHexBack(badAckFrame);
    //remote receives goAway
    GoAwayFrame goAway = (GoAwayFrame) mockChannel.getFrameAndClear();
    DataWrapper debugData = goAway.getDebugData();
    String msg = debugData.createStringFromUtf8(0, debugData.getReadableSize());
    Assert.assertEquals("ConnectionException: stream0:(FRAME_SIZE_INCORRECT) size of payload of a settings frame ack must be 0 but was=1", msg);
    Assert.assertTrue(mockChannel.isClosed());
}
Also used : DataWrapper(org.webpieces.data.api.DataWrapper) HeaderSettings(com.webpieces.http2engine.impl.shared.data.HeaderSettings) GoAwayFrame(com.webpieces.http2parser.api.dto.GoAwayFrame) Test(org.junit.Test)

Example 8 with HeaderSettings

use of com.webpieces.http2engine.impl.shared.data.HeaderSettings 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());
}
Also used : SettingsFrame(com.webpieces.http2parser.api.dto.SettingsFrame) HeaderSettings(com.webpieces.http2engine.impl.shared.data.HeaderSettings) RequestsSent(org.webpieces.http2client.util.RequestsSent) Http2Msg(com.webpieces.http2parser.api.dto.lib.Http2Msg) Test(org.junit.Test)

Example 9 with HeaderSettings

use of com.webpieces.http2engine.impl.shared.data.HeaderSettings in project webpieces by deanhiller.

the class AbstractTest method sendAndAckSettingsFrame.

private void sendAndAckSettingsFrame(long max) throws InterruptedException, ExecutionException {
    //server's settings frame is finally coming in as well with maxConcurrent=1
    HeaderSettings settings = new HeaderSettings();
    settings.setMaxConcurrentStreams(max);
    mockChannel.write(HeaderSettings.createSettingsFrame(settings));
    //ack client frame
    mockChannel.write(new SettingsFrame(true));
    SettingsFrame ack = (SettingsFrame) mockChannel.getFrameAndClear();
    Assert.assertEquals(true, ack.isAck());
}
Also used : SettingsFrame(com.webpieces.http2parser.api.dto.SettingsFrame) HeaderSettings(com.webpieces.http2engine.impl.shared.data.HeaderSettings)

Aggregations

HeaderSettings (com.webpieces.http2engine.impl.shared.data.HeaderSettings)9 SettingsFrame (com.webpieces.http2parser.api.dto.SettingsFrame)5 Http2Msg (com.webpieces.http2parser.api.dto.lib.Http2Msg)5 Test (org.junit.Test)5 StreamWriter (com.webpieces.http2engine.api.StreamWriter)1 DataFrame (com.webpieces.http2parser.api.dto.DataFrame)1 GoAwayFrame (com.webpieces.http2parser.api.dto.GoAwayFrame)1 DataWrapper (org.webpieces.data.api.DataWrapper)1 Preface (org.webpieces.http2client.mock.Preface)1 RequestsSent (org.webpieces.http2client.util.RequestsSent)1