use of org.webpieces.http2client.api.Http2Socket in project webpieces by deanhiller.
the class TestC6_5SettingsFrameErrors 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.addTCPChannelToReturn(mockChannel);
socket = client.createHttpSocket("simple");
CompletableFuture<Http2Socket> connect = socket.connect(new InetSocketAddress(555));
Assert.assertTrue(connect.isDone());
Assert.assertEquals(socket, connect.get());
//clear preface and settings frame from client
mockChannel.getFramesAndClear();
}
use of org.webpieces.http2client.api.Http2Socket in project webpieces by deanhiller.
the class AbstractTest 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);
localSettings.setInitialWindowSize(localSettings.getMaxFrameSize() * 4);
config.setLocalSettings(localSettings);
InjectionConfig injConfig = new InjectionConfig(mockTime, config);
Http2Client client = Http2ClientFactory.createHttpClient(mockChanMgr, injConfig);
mockChanMgr.addTCPChannelToReturn(mockChannel);
httpSocket = client.createHttpSocket("simple");
CompletableFuture<Http2Socket> connect = httpSocket.connect(new InetSocketAddress(555));
Assert.assertTrue(connect.isDone());
Assert.assertEquals(httpSocket, connect.get());
//clear preface and settings frame from client
mockChannel.getFramesAndClear();
//server's settings frame is finally coming in as well with maxConcurrent=1
sendAndAckSettingsFrame(1);
}
use of org.webpieces.http2client.api.Http2Socket in project webpieces by deanhiller.
the class IntegMultiThreaded method main.
public static void main(String[] args) throws InterruptedException {
boolean isHttp = true;
String path = "/";
//String host = www.google.com;
//String host = "localhost"; //jetty
String host = "nghttp2.org";
int port = 443;
if (isHttp)
port = 80;
if (host.equals("localhost")) {
//IF jetty, use a path with a bigger download
path = "/test/data.txt";
port = 8443;
if (isHttp)
port = 8080;
}
List<Http2Header> req = createRequest(host, isHttp, path);
log.info("starting socket");
InetSocketAddress addr = new InetSocketAddress(host, port);
Http2Socket socket = IntegSingleRequest.createHttpClient("clientSocket", isHttp, addr);
socket.connect(addr).thenApply(s -> {
for (int i = 0; i < 99; i += 100) {
executor.execute(new WorkItem(socket, req, i, i));
}
return s;
}).exceptionally(e -> {
reportException(socket, e);
return null;
});
Thread.sleep(100000000);
}
Aggregations