use of org.webpieces.http2client.mock.Preface 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 org.webpieces.http2client.mock.Preface in project webpieces by deanhiller.
the class TestC3InitialHttpsConnections method setUp.
@Before
public void setUp() throws InterruptedException, ExecutionException {
mockChannel.setIncomingFrameDefaultReturnValue(CompletableFuture.completedFuture(mockChannel));
Http2Config config = new Http2Config();
//start with 1 max concurrent
config.setInitialRemoteMaxConcurrent(1);
config.setLocalSettings(localSettings);
InjectionConfig injConfig = new InjectionConfig(mockTime, config);
Http2Client client = Http2ClientFactory.createHttpClient(mockChanMgr, injConfig);
mockChanMgr.addSSLChannelToReturn(mockChannel);
InetSocketAddress addr = new InetSocketAddress("somehost.com", 555);
String host = addr.getHostName();
int port = addr.getPort();
ForTestSslClientEngineFactory ssl = new ForTestSslClientEngineFactory();
SSLEngine engine = ssl.createSslEngine(host, port);
socket = client.createHttpsSocket("simple", engine);
CompletableFuture<Http2Socket> connect = socket.connect(addr);
Assert.assertTrue(connect.isDone());
Assert.assertEquals(socket, connect.get());
//verify settings on connect were sent
//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);
}
Aggregations