use of org.eclipse.jetty.http2.client.HTTP2Client in project jetty.project by eclipse.
the class FlowControlStalledTest method start.
protected void start(FlowControlStrategy.Factory flowControlFactory, ServerSessionListener listener) throws Exception {
QueuedThreadPool serverExecutor = new QueuedThreadPool();
serverExecutor.setName("server");
server = new Server(serverExecutor);
RawHTTP2ServerConnectionFactory connectionFactory = new RawHTTP2ServerConnectionFactory(new HttpConfiguration(), listener);
connectionFactory.setFlowControlStrategyFactory(flowControlFactory);
connector = new ServerConnector(server, connectionFactory);
server.addConnector(connector);
server.start();
client = new HTTP2Client();
QueuedThreadPool clientExecutor = new QueuedThreadPool();
clientExecutor.setName("client");
client.setExecutor(clientExecutor);
client.setFlowControlStrategyFactory(flowControlFactory);
client.start();
}
use of org.eclipse.jetty.http2.client.HTTP2Client in project jetty.project by eclipse.
the class FlowControlStrategyTest method start.
protected void start(ServerSessionListener listener) throws Exception {
QueuedThreadPool serverExecutor = new QueuedThreadPool();
serverExecutor.setName("server");
server = new Server(serverExecutor);
RawHTTP2ServerConnectionFactory connectionFactory = new RawHTTP2ServerConnectionFactory(new HttpConfiguration(), listener);
connectionFactory.setFlowControlStrategyFactory(FlowControlStrategyTest.this::newFlowControlStrategy);
connector = new ServerConnector(server, connectionFactory);
server.addConnector(connector);
server.start();
client = new HTTP2Client();
QueuedThreadPool clientExecutor = new QueuedThreadPool();
clientExecutor.setName("client");
client.setExecutor(clientExecutor);
client.setFlowControlStrategyFactory(FlowControlStrategyTest.this::newFlowControlStrategy);
client.start();
}
use of org.eclipse.jetty.http2.client.HTTP2Client in project jetty.project by eclipse.
the class HTTP2Test method testMultipleRequests.
@Test
public void testMultipleRequests() throws Exception {
final String downloadBytes = "X-Download";
start(new HttpServlet() {
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
int download = request.getIntHeader(downloadBytes);
byte[] content = new byte[download];
new Random().nextBytes(content);
response.getOutputStream().write(content);
}
});
int requests = 20;
Session session = newClient(new Session.Listener.Adapter());
Random random = new Random();
HttpFields fields = new HttpFields();
fields.putLongField(downloadBytes, random.nextInt(128 * 1024));
fields.put("User-Agent", "HTTP2Client/" + Jetty.VERSION);
MetaData.Request metaData = newRequest("GET", fields);
HeadersFrame frame = new HeadersFrame(metaData, null, true);
final CountDownLatch latch = new CountDownLatch(requests);
for (int i = 0; i < requests; ++i) {
session.newStream(frame, new Promise.Adapter<>(), new Stream.Listener.Adapter() {
@Override
public void onData(Stream stream, DataFrame frame, Callback callback) {
callback.succeeded();
if (frame.isEndStream())
latch.countDown();
}
});
}
Assert.assertTrue(latch.await(requests, TimeUnit.SECONDS));
}
use of org.eclipse.jetty.http2.client.HTTP2Client in project jetty.project by eclipse.
the class DirectHTTP2OverTLSTest method startClient.
private void startClient() throws Exception {
QueuedThreadPool clientThreads = new QueuedThreadPool();
clientThreads.setName("client");
HttpClientTransportOverHTTP2 transport = new HttpClientTransportOverHTTP2(new HTTP2Client());
transport.setUseALPN(false);
client = new HttpClient(transport, newSslContextFactory());
client.setExecutor(clientThreads);
client.start();
}
use of org.eclipse.jetty.http2.client.HTTP2Client in project jetty.project by eclipse.
the class HttpClientTransportOverHTTP2Test method testPropertiesAreForwarded.
@Test
public void testPropertiesAreForwarded() throws Exception {
HTTP2Client http2Client = new HTTP2Client();
HttpClient httpClient = new HttpClient(new HttpClientTransportOverHTTP2(http2Client), null);
Executor executor = new QueuedThreadPool();
httpClient.setExecutor(executor);
httpClient.setConnectTimeout(13);
httpClient.setIdleTimeout(17);
httpClient.start();
Assert.assertTrue(http2Client.isStarted());
Assert.assertSame(httpClient.getExecutor(), http2Client.getExecutor());
Assert.assertSame(httpClient.getScheduler(), http2Client.getScheduler());
Assert.assertSame(httpClient.getByteBufferPool(), http2Client.getByteBufferPool());
Assert.assertEquals(httpClient.getConnectTimeout(), http2Client.getConnectTimeout());
Assert.assertEquals(httpClient.getIdleTimeout(), http2Client.getIdleTimeout());
httpClient.stop();
Assert.assertTrue(http2Client.isStopped());
}
Aggregations