Module java.httpclient
Package java.net.http

## Interface HttpResponse.MultiProcessor<T>

Type Parameters:
  `T` - a type representing the aggregated results

Enclosing class:
  HttpResponse

    public static interface HttpResponse.MultiProcessor<T>

A response processor for a HTTP/2 multi response. A multi response comprises a main response, and zero or more additional responses. Each additional response is sent by the server in response to requests that the server also generates. Additional responses are typically resources that the server guesses the client will need which are related to the initial request.

The server generated requests are also known as push promises. The server is permitted to send any number of these requests up to the point where the main response is fully received. Therefore, after completion of the main response body, the final number of additional responses is known. Additional responses may be cancelled, but given that the server does not wait for any acknowledgment before sending the response, this must be done quickly to avoid unnecessary data transmission.

`MultiProcessor`s are parameterised with a type `T` which represents some meaningful aggregate of the responses received. This would typically be a Collection of response or response body objects. One example implementation can be found at `HttpResponse.multiFile(java.nio.file.Path)`.

Since:
  9

### Method Summary

All Methods Instance Methods Abstract Methods
`T` `onComplete()` Called after all responses associated with the multi response have been fully processed, including response bodies.
`BiFunction<HttpRequest,CompletableFuture<HttpResponse>,Boolean>` `onStart(HttpRequest mainRequest, CompletableFuture<HttpResponse> response)` Called before or soon after a multi request is sent.

### Method Detail

#### onStart

    BiFunction<HttpRequest,CompletableFuture<HttpResponse>,Boolean> onStart(HttpRequest mainRequest,
                                                                            CompletableFuture<HttpResponse> response)

Called before or soon after a multi request is sent. The request that initiated the multi response is supplied, as well as a CompletableFuture for the main response. The implementation of this method must return a BiFunction which is called once for each push promise received.

The parameters to the `BiFunction` are the `HttpRequest` for the push promise and a `CompletableFuture` for its response. The function must return a Boolean indicating whether the push promise has been accepted (true) or should be canceled (false). The CompletableFutures for any canceled pushes are themselves completed exceptionally soon after the function returns.

Parameters:
  `mainRequest` - the main request
  `response` - a CompletableFuture for the main response
Returns:
  a BiFunction that is called for each push promise

#### onComplete

    T onComplete()

Called after all responses associated with the multi response have been fully processed, including response bodies.

Example types for `T` could be Collections of response body types or `Map`s from request `URI` to a response body type.

Returns:
  the aggregate response object