Java Examples for okhttp3.internal.http2.Settings.MAX_CONCURRENT_STREAMS
The following java examples will help you to understand the usage of okhttp3.internal.http2.Settings.MAX_CONCURRENT_STREAMS. These source code samples are taken from different open source projects.
Example 1
| Project: okhttp-master File: Http2ConnectionTest.java View source code |
@Test
public void serverSendsSettingsToClient() throws Exception {
// write the mocking script
final Settings settings = new Settings();
settings.set(MAX_CONCURRENT_STREAMS, 10);
peer.sendFrame().settings(settings);
// ACK
peer.acceptFrame();
peer.sendFrame().ping(false, 2, 0);
// PING
peer.acceptFrame();
peer.play();
// play it back
final CountDownLatch maxConcurrentStreamsUpdated = new CountDownLatch(1);
final AtomicInteger maxConcurrentStreams = new AtomicInteger();
Http2Connection.Listener listener = new Http2Connection.Listener() {
@Override
public void onStream(Http2Stream stream) throws IOException {
throw new AssertionError();
}
@Override
public void onSettings(Http2Connection connection) {
maxConcurrentStreams.set(connection.maxConcurrentStreams());
maxConcurrentStreamsUpdated.countDown();
}
};
Http2Connection connection = connect(peer, IGNORE, listener);
synchronized (connection) {
assertEquals(10, connection.peerSettings.getMaxConcurrentStreams(-1));
}
maxConcurrentStreamsUpdated.await();
assertEquals(10, maxConcurrentStreams.get());
}