src/java.net.http/share/classes/java/net/http/HttpClient.java
branchhttp-client-branch
changeset 56203 be57b0428d84
parent 56202 00e183f919a1
child 56278 8bc5fb608e30
equal deleted inserted replaced
56202:00e183f919a1 56203:be57b0428d84
    61  *
    61  *
    62  * <p> A {@link BodyHandler BodyHandler} must be supplied for each {@link
    62  * <p> A {@link BodyHandler BodyHandler} must be supplied for each {@link
    63  * HttpRequest} sent. The {@code BodyHandler} determines how to handle the
    63  * HttpRequest} sent. The {@code BodyHandler} determines how to handle the
    64  * response body, if any. Once an {@link HttpResponse} is received, the
    64  * response body, if any. Once an {@link HttpResponse} is received, the
    65  * headers, response code, and body (typically) are available. Whether the
    65  * headers, response code, and body (typically) are available. Whether the
    66  * response body bytes has been read or not depends on the type, {@code T}, of
    66  * response body bytes have been read or not depends on the type, {@code T}, of
    67  * the response body.
    67  * the response body.
    68  *
    68  *
    69  * <p> Requests can be sent either synchronously or asynchronously:
    69  * <p> Requests can be sent either synchronously or asynchronously:
    70  * <ul>
    70  * <ul>
    71  *     <li>{@link HttpClient#send(HttpRequest, BodyHandler)} blocks
    71  *     <li>{@link HttpClient#send(HttpRequest, BodyHandler)} blocks
    80  *     declare dependencies among several asynchronous tasks.</li>
    80  *     declare dependencies among several asynchronous tasks.</li>
    81  * </ul>
    81  * </ul>
    82  *
    82  *
    83  * <p><b>Synchronous Example</b>
    83  * <p><b>Synchronous Example</b>
    84  * <pre>{@code    HttpClient client = HttpClient.newBuilder()
    84  * <pre>{@code    HttpClient client = HttpClient.newBuilder()
    85  *        .version(Version.HTTP_1)
    85  *        .version(Version.HTTP_1_1)
    86  *        .followRedirects(Redirect.SAME_PROTOCOL)
    86  *        .followRedirects(Redirect.SAME_PROTOCOL)
    87  *        .proxy(ProxySelector.of(new InetSocketAddress("proxy.example.com", 80)))
    87  *        .proxy(ProxySelector.of(new InetSocketAddress("proxy.example.com", 80)))
    88  *        .authenticator(Authenticator.getDefault())
    88  *        .authenticator(Authenticator.getDefault())
    89  *        .build();
    89  *        .build();
    90  *   HttpResponse<String> response = client.send(request, BodyHandlers.ofString());
    90  *   HttpResponse<String> response = client.send(request, BodyHandlers.ofString());