3

I'm using vertx.io to make several HTTP requests, the input to the program is a file containing several full URLs. Checking the vertx.io HttpClient it seems like it can only query hosts but not full URLs. For example: it will successfully query http://www.yahoo.com/ but will fail on something like: http://finance.yahoo.com/news/us-stocks-slip-wal-mart-154834426.html

And so my questions are:

  1. Is it possible to query the full URL using the Vertx.io native HttpClient?
  2. Is it possible to use other HttpClients with vertx? For example use Apache asynchronous HTTP client with callbacks and vertx?

Googling these didn't find any good answers...

Thanks in advance!

Gideon
  • 2,211
  • 5
  • 29
  • 47

1 Answers1

6

1: You can use the getAbs method:

client.getAbs("http://finance.yahoo.com/news/us-stocks-slip-wal-mart-154834426.html", response -> {
  System.out.println("Received response with status code " + response.statusCode());
}).end();

Vertx HttpClient documentation

2: If you use it with the FutureCallback<HttpResponse> callback parameter then it won't block the event loop.

cy3er
  • 1,699
  • 11
  • 14
  • cy3er why would the Apace async HttpClient block? – Gideon Feb 21 '16 at 12:31
  • @Gideon: edited again, I got confused by the fact that it returns a future, but it also has a callback parameter, which - of course - won't block. – cy3er Feb 22 '16 at 13:55
  • so basically I can just as well use the Apache's async client instead of the native vertx httpclient? – Gideon Feb 22 '16 at 16:14