37 import java.util.concurrent.Executor; |
37 import java.util.concurrent.Executor; |
38 import java.util.concurrent.Executors; |
38 import java.util.concurrent.Executors; |
39 import java.util.concurrent.ThreadFactory; |
39 import java.util.concurrent.ThreadFactory; |
40 import javax.net.ssl.SSLContext; |
40 import javax.net.ssl.SSLContext; |
41 import javax.net.ssl.SSLParameters; |
41 import javax.net.ssl.SSLParameters; |
|
42 import jdk.incubator.http.HttpResponse.BodyHandler; |
|
43 import jdk.incubator.http.HttpResponse.PushPromiseHandler; |
42 |
44 |
43 /** |
45 /** |
44 * A container for configuration information common to multiple {@link |
46 * A container for configuration information common to multiple {@link |
45 * HttpRequest}s. All requests are sent through a {@code HttpClient}. |
47 * HttpRequest}s. All requests are sent through a {@code HttpClient}. |
46 * {@Incubating} |
48 * {@Incubating} |
445 * @param req the request |
447 * @param req the request |
446 * @param responseBodyHandler the response body handler |
448 * @param responseBodyHandler the response body handler |
447 * @return a {@code CompletableFuture<HttpResponse<T>>} |
449 * @return a {@code CompletableFuture<HttpResponse<T>>} |
448 */ |
450 */ |
449 public abstract <T> CompletableFuture<HttpResponse<T>> |
451 public abstract <T> CompletableFuture<HttpResponse<T>> |
450 sendAsync(HttpRequest req, HttpResponse.BodyHandler<T> responseBodyHandler); |
452 sendAsync(HttpRequest req, |
451 |
453 BodyHandler<T> responseBodyHandler); |
452 /** |
454 |
453 * Sends the given request asynchronously using this client and the given |
455 /** |
454 * multi response handler. |
456 * Sends the given request asynchronously using this client with the given |
455 * |
457 * response body handler and push promise handler. |
456 * <p> The returned completable future completes exceptionally with: |
458 * |
457 * <ul> |
459 * @param <T> the response body type |
458 * <li>{@link IOException} - if an I/O error occurs when sending or receiving</li> |
|
459 * <li>{@link IllegalArgumentException} - if the request method is not supported</li> |
|
460 * <li>{@link SecurityException} - If a security manager has been installed |
|
461 * and it denies {@link java.net.URLPermission access} to the |
|
462 * URL in the given request, or proxy if one is configured. |
|
463 * See HttpRequest for further information about |
|
464 * <a href="HttpRequest.html#securitychecks">security checks</a>.</li> |
|
465 * </ul> |
|
466 * |
|
467 * @param <U> a type representing the aggregated results |
|
468 * @param <T> a type representing all of the response bodies |
|
469 * @param req the request |
460 * @param req the request |
470 * @param multiSubscriber the multiSubscriber for the request |
461 * @param responseBodyHandler the response body handler |
471 * @return a {@code CompletableFuture<U>} |
462 * @param pushPromiseHandler push promise handler, may be null |
472 */ |
463 * @return a {@code CompletableFuture<HttpResponse<T>>} |
473 public abstract <U, T> CompletableFuture<U> |
464 */ |
474 sendAsync(HttpRequest req, HttpResponse.MultiSubscriber<U, T> multiSubscriber); |
465 public abstract <T> CompletableFuture<HttpResponse<T>> |
|
466 sendAsync(HttpRequest req, |
|
467 BodyHandler<T> responseBodyHandler, |
|
468 PushPromiseHandler<T> pushPromiseHandler); |
475 |
469 |
476 /** |
470 /** |
477 * Creates a new {@code WebSocket} builder (optional operation). |
471 * Creates a new {@code WebSocket} builder (optional operation). |
478 * |
472 * |
479 * <p> <b>Example</b> |
473 * <p> <b>Example</b> |