use of io.vertx.core.http.HttpClient in project vert.x by eclipse.
the class HTTP2Examples method useMaxStreams.
public void useMaxStreams(Vertx vertx) {
HttpClientOptions clientOptions = new HttpClientOptions().setHttp2MultiplexingLimit(10).setHttp2MaxPoolSize(3);
// Uses up to 3 connections and up to 10 streams per connection
HttpClient client = vertx.createHttpClient(clientOptions);
}
use of io.vertx.core.http.HttpClient in project vert.x by eclipse.
the class HTTP2Examples method example8.
public void example8(Vertx vertx) {
HttpClientOptions options = new HttpClientOptions().setProtocolVersion(HttpVersion.HTTP_2);
HttpClient client = vertx.createHttpClient(options);
}
use of io.vertx.core.http.HttpClient in project vert.x by eclipse.
the class VertxImpl method createHttpClient.
public HttpClient createHttpClient(HttpClientOptions options) {
CloseFuture closeFuture = new CloseFuture();
HttpClient client;
if (options.isShared()) {
client = createSharedClient(SharedHttpClient.SHARED_MAP_NAME, options.getName(), closeFuture, cf -> createHttpClient(options, cf));
client = new SharedHttpClient(this, closeFuture, client);
} else {
client = createHttpClient(options, closeFuture);
}
resolveCloseFuture().add(closeFuture);
return client;
}
use of io.vertx.core.http.HttpClient in project vert.x by eclipse.
the class HostnameResolutionTest method testHttp.
@Test
public void testHttp() throws Exception {
HttpClient client = vertx.createHttpClient();
HttpServer server = vertx.createHttpServer().requestHandler(req -> {
req.response().end("foo");
});
try {
CountDownLatch listenLatch = new CountDownLatch(1);
server.listen(8080, "vertx.io", onSuccess(s -> {
listenLatch.countDown();
}));
awaitLatch(listenLatch);
client.request(HttpMethod.GET, 8080, "vertx.io", "/somepath", onSuccess(req -> {
req.send(onSuccess(resp -> {
Buffer buffer = Buffer.buffer();
resp.handler(buffer::appendBuffer);
resp.endHandler(v -> {
assertEquals(Buffer.buffer("foo"), buffer);
testComplete();
});
}));
}));
await();
} finally {
client.close();
server.close();
}
}
use of io.vertx.core.http.HttpClient in project vert.x by eclipse.
the class NettyCompatTest method testHttp2.
@Test
public void testHttp2() {
vertx.createHttpServer(new HttpServerOptions().setUseAlpn(true).setSsl(true).setSslEngineOptions(new OpenSSLEngineOptions()).setKeyCertOptions(Cert.SERVER_JKS.get())).requestHandler(req -> req.response().end("OK")).listen(8443, "localhost", onSuccess(s -> {
HttpClient client = vertx.createHttpClient(new HttpClientOptions().setSsl(true).setSslEngineOptions(new OpenSSLEngineOptions()).setTrustStoreOptions(Trust.SERVER_JKS.get()));
client.request(HttpMethod.GET, 8443, "localhost", "/somepath", onSuccess(req -> {
req.send(onSuccess(resp -> {
resp.bodyHandler(buff -> {
assertEquals("OK", buff.toString());
testComplete();
});
}));
}));
}));
await();
}
Aggregations