Package java.net.http

Interface HttpRequest.Builder

Enclosing class:
HttpRequest

public static interface HttpRequest.Builder
A builder of HTTP requests.

Instances of HttpRequest.Builder are created by calling HttpRequest.newBuilder(), HttpRequest.newBuilder(URI), or HttpRequest.newBuilder(HttpRequest, BiPredicate).

The builder can be used to configure per-request state, such as: the request URI, the request method (default is GET unless explicitly set), specific request headers, etc. Each of the setter methods modifies the state of the builder and returns the same instance. The methods are not synchronized and should not be called from multiple threads without external synchronization. The build method returns a new HttpRequest each time it is invoked. Once built an HttpRequest is immutable, and can be sent multiple times.

Note, that not all request headers may be set by user code. Some are restricted for security reasons and others such as the headers relating to authentication, redirection and cookie management may be managed by specific APIs rather than through directly user set headers.

Since:
11