Example usage for io.vertx.core.http HttpClientRequest pushHandler

List of usage examples for io.vertx.core.http HttpClientRequest pushHandler

Introduction

In this page you can find the example usage for io.vertx.core.http HttpClientRequest pushHandler.

Prototype

@Fluent
HttpClientRequest pushHandler(Handler<HttpClientRequest> handler);

Source Link

Document

Set a push handler for this request.

The handler is called when the client receives a push promise from the server.

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  .  ja va2  s .c  o 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.HTTP2Examples.java

License:Open Source License

public void example14(HttpClientRequest request) {
    request.pushHandler(pushedRequest -> {
        if (pushedRequest.path().equals("/main.js")) {
            pushedRequest.reset();/*from w  w  w  .  ja v a2s .c  o m*/
        } else {
            // Handle it
        }
    });
}