< prev index next >

src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpResponse.java

Print this page




 601          */
 602         void onResponse(HttpResponse<T> response);
 603 
 604         /**
 605          * Called if an error occurs receiving a response. For each request
 606          * either one of onResponse() or onError() is guaranteed to be called,
 607          * but not both.
 608          *
 609          * @param request the main request or subsequent push promise
 610          * @param t the Throwable that caused the error
 611          */
 612         void onError(HttpRequest request, Throwable t);
 613 
 614         /**
 615          * Returns a {@link java.util.concurrent.CompletableFuture}{@code <U>}
 616          * which completes when the aggregate result object itself is available.
 617          * It is expected that the returned {@code CompletableFuture} will depend
 618          * on one of the given {@code CompletableFuture<Void}s which themselves complete
 619          * after all individual responses associated with the multi response
 620          * have completed, or after all push promises have been received.
 621          * <p>
 622          * @implNote Implementations might follow the pattern shown below
 623          * <pre>
 624          * {@code
 625          *      CompletableFuture<U> completion(
 626          *              CompletableFuture<Void> onComplete,
 627          *              CompletableFuture<Void> onFinalPushPromise)
 628          *      {
 629          *          return onComplete.thenApply((v) -> {
 630          *              U u = ... instantiate and populate a U instance
 631          *              return u;
 632          *          });
 633          *      }
 634          * }
 635          * </pre>
 636          * <p>
 637          *
 638          * @param onComplete a CompletableFuture which completes after all
 639          * responses have been received relating to this multi request.
 640          *
 641          * @param onFinalPushPromise CompletableFuture which completes after all
 642          * push promises have been received.
 643          *
 644          * @return the aggregate CF response object
 645          */
 646         CompletableFuture<U> completion(CompletableFuture<Void> onComplete,
 647                 CompletableFuture<Void> onFinalPushPromise);
 648 
 649         /**
 650          * Returns a general purpose handler for multi responses. The aggregated
 651          * result object produced by this handler is a
 652          * {@code Map<HttpRequest,CompletableFuture<HttpResponse<V>>>}. Each
 653          * request (both the original user generated request and each server
 654          * generated push promise) is returned as a key of the map. The value
 655          * corresponding to each key is a
 656          * {@code CompletableFuture<HttpResponse<V>>}.




 601          */
 602         void onResponse(HttpResponse<T> response);
 603 
 604         /**
 605          * Called if an error occurs receiving a response. For each request
 606          * either one of onResponse() or onError() is guaranteed to be called,
 607          * but not both.
 608          *
 609          * @param request the main request or subsequent push promise
 610          * @param t the Throwable that caused the error
 611          */
 612         void onError(HttpRequest request, Throwable t);
 613 
 614         /**
 615          * Returns a {@link java.util.concurrent.CompletableFuture}{@code <U>}
 616          * which completes when the aggregate result object itself is available.
 617          * It is expected that the returned {@code CompletableFuture} will depend
 618          * on one of the given {@code CompletableFuture<Void}s which themselves complete
 619          * after all individual responses associated with the multi response
 620          * have completed, or after all push promises have been received.
 621          *
 622          * @implNote Implementations might follow the pattern shown below
 623          * <pre>
 624          * {@code
 625          *      CompletableFuture<U> completion(
 626          *              CompletableFuture<Void> onComplete,
 627          *              CompletableFuture<Void> onFinalPushPromise)
 628          *      {
 629          *          return onComplete.thenApply((v) -> {
 630          *              U u = ... instantiate and populate a U instance
 631          *              return u;
 632          *          });
 633          *      }
 634          * }
 635          * </pre>

 636          *
 637          * @param onComplete a CompletableFuture which completes after all
 638          * responses have been received relating to this multi request.
 639          *
 640          * @param onFinalPushPromise CompletableFuture which completes after all
 641          * push promises have been received.
 642          *
 643          * @return the aggregate CF response object
 644          */
 645         CompletableFuture<U> completion(CompletableFuture<Void> onComplete,
 646                 CompletableFuture<Void> onFinalPushPromise);
 647 
 648         /**
 649          * Returns a general purpose handler for multi responses. The aggregated
 650          * result object produced by this handler is a
 651          * {@code Map<HttpRequest,CompletableFuture<HttpResponse<V>>>}. Each
 652          * request (both the original user generated request and each server
 653          * generated push promise) is returned as a key of the map. The value
 654          * corresponding to each key is a
 655          * {@code CompletableFuture<HttpResponse<V>>}.


< prev index next >