use of io.vertx.core.http.HttpClient in project vert.x by eclipse.
the class HTTP2Examples method example7.
public void example7(Vertx vertx) {
HttpClientOptions options = new HttpClientOptions().setProtocolVersion(HttpVersion.HTTP_2).setSsl(true).setUseAlpn(true).setTrustAll(true);
HttpClient client = vertx.createHttpClient(options);
}
use of io.vertx.core.http.HttpClient in project vert.x by eclipse.
the class JsonTest method testHttp.
@Test
public void testHttp() {
Vertx vertx = Vertx.vertx();
try {
vertx.createHttpServer().requestHandler(req -> {
req.response().end("hello");
}).listen(DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, onSuccess(s -> {
HttpClient client = vertx.createHttpClient();
client.request(HttpMethod.GET, DEFAULT_HTTP_PORT, DEFAULT_HTTP_HOST, "/").compose(req -> req.send().compose(HttpClientResponse::body)).onComplete(onSuccess(body -> {
assertEquals("hello", body.toString());
testComplete();
}));
}));
await();
} finally {
vertx.close();
}
}
Aggregations