Path: blob/master/src/java.net.http/share/classes/java/net/http/package-info.java
41159 views
/*1* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425/**26* <h2>HTTP Client and WebSocket APIs</h2>27*28* <p> Provides high-level client interfaces to HTTP (versions 1.1 and 2) and29* low-level client interfaces to WebSocket. The main types defined are:30*31* <ul>32* <li>{@link java.net.http.HttpClient}</li>33* <li>{@link java.net.http.HttpRequest}</li>34* <li>{@link java.net.http.HttpResponse}</li>35* <li>{@link java.net.http.WebSocket}</li>36* </ul>37*38* <p> The protocol-specific requirements are defined in the39* <a href="https://tools.ietf.org/html/rfc7540">Hypertext Transfer Protocol40* Version 2 (HTTP/2)</a>, the <a href="https://tools.ietf.org/html/rfc2616">41* Hypertext Transfer Protocol (HTTP/1.1)</a>, and42* <a href="https://tools.ietf.org/html/rfc6455">The WebSocket Protocol</a>.43*44* <p> In general, asynchronous tasks execute in either the thread invoking45* the operation, e.g. {@linkplain HttpClient#send(HttpRequest, BodyHandler)46* sending} an HTTP request, or by the threads supplied by the client's {@link47* HttpClient#executor() executor}. Dependent tasks, those that are triggered by48* returned CompletionStages or CompletableFutures, that do not explicitly49* specify an executor, execute in the same {@link50* CompletableFuture#defaultExecutor() default executor} as that of {@code51* CompletableFuture}, or the invoking thread if the operation completes before52* the dependent task is registered.53*54* <p> {@code CompletableFuture}s returned by this API will throw {@link55* UnsupportedOperationException} for their {@link56* CompletableFuture#obtrudeValue(Object) obtrudeValue}57* and {@link CompletableFuture#obtrudeException(Throwable)58* obtrudeException} methods. Invoking the {@link CompletableFuture#cancel59* cancel} method on a {@code CompletableFuture} returned by this API may not60* interrupt the underlying operation, but may be useful to complete,61* exceptionally, dependent stages that have not already completed.62*63* <p> Unless otherwise stated, {@code null} parameter values will cause methods64* of all classes in this package to throw {@code NullPointerException}.65*66* @since 1167*/68package java.net.http;6970import java.lang.UnsupportedOperationException;71import java.net.http.HttpClient;72import java.net.http.HttpRequest;73import java.net.http.HttpResponse.BodyHandler;74import java.util.concurrent.CompletableFuture;757677