Example usage for io.vertx.core.http HttpClient get

List of usage examples for io.vertx.core.http HttpClient get

Introduction

In this page you can find the example usage for io.vertx.core.http HttpClient get.

Prototype

HttpClientRequest get(String requestURI, Handler<AsyncResult<HttpClientResponse>> responseHandler);

Source Link

Document

Create an HTTP GET request to send to the server at the default host and port, specifying a response handler to receive the response

Usage

From source file:examples.HTTP2Examples.java

License:Open Source License

public void example13(HttpClient client) {

    HttpClientRequest request = client.get("/index.html", response -> {
        // Process index.html response
    });//from  w  w  w .  j  a  v  a 2  s .co m

    // Set a push handler to be aware of any resource pushed by the server
    request.pushHandler(pushedRequest -> {

        // A resource is pushed for this request
        System.out.println("Server pushed " + pushedRequest.path());

        // Set an handler for the response
        pushedRequest.handler(pushedResponse -> {
            System.out.println("The response for the pushed request");
        });
    });

    // End the request
    request.end();
}

From source file:examples.HTTPExamples.java

License:Open Source License

public void exampleFollowRedirect01(HttpClient client) {

    client.get("some-uri", response -> {
        System.out.println("Received response with status code " + response.statusCode());
    }).setFollowRedirects(true).end();/*from   w  w  w  .ja  v  a2  s  .co m*/
}

From source file:examples.HTTPExamples.java

License:Open Source License

public void exampleFollowRedirect02(Vertx vertx) {

    HttpClient client = vertx.createHttpClient(new HttpClientOptions().setMaxRedirects(32));

    client.get("some-uri", response -> {
        System.out.println("Received response with status code " + response.statusCode());
    }).setFollowRedirects(true).end();/*  ww  w. j av a2 s  .c  om*/
}