vertx-httpclient

Vertx HttpClient getNow not working

我怕爱的太早我们不能终老 提交于 2020-05-13 14:47:09
问题 I have problem with vertx HttpClient. Here's code which shows that tests GET using vertx and plain java. Vertx vertx = Vertx.vertx(); HttpClientOptions options = new HttpClientOptions() .setTrustAll(true) .setSsl(false) .setDefaultPort(80) .setProtocolVersion(HttpVersion.HTTP_1_1) .setLogActivity(true); HttpClient client = vertx.createHttpClient(options); client.getNow("google.com", "/", response -> { System.out.println("Received response with status code " + response.statusCode()); });

Keep getting errors when running JUnit test on my http client

孤街浪徒 提交于 2019-12-13 03:56:01
问题 I am creating a client to send requests to an API, and I am trying to write a Junit test but i keep getting this error. Here is my client code which sends a request: import io.netty.handler.codec.http.HttpResponse; import io.vertx.core.AsyncResult; import io.vertx.core.buffer.Buffer; import io.vertx.core.json.JsonObject; import io.vertx.core.logging.Logger; import io.vertx.core.logging.LoggerFactory; import io.vertx.ext.web.client.HttpRequest; import io.vertx.ext.web.client.WebClient; public

In Vert.x web client, can I map a JSON response to a collection of POJOs?

一个人想着一个人 提交于 2019-12-11 07:05:36
问题 In Vert.x Web client manual there's an example of decoding an incoming JSON response into a POJO: client .get(8080, "myserver.mycompany.com", "/some-uri") .as(BodyCodec.json(User.class)) .send(ar -> { // Process the response }) Is there a way to decode an incoming JSON array into a collection of objects? 回答1: I don't believe you can use a BodyCodec to convert the content straight to a collection of objects. However you use Vert.x core Json class with the body as Buffer client .get(8080,