Package java.net.http

Class HttpHeaders

java.lang.Object
java.net.http.HttpHeaders

public final class HttpHeaders extends Object
A read-only view of a set of HTTP headers.

An HttpHeaders is not typically created directly, but rather returned from an HttpRequest or an HttpResponse. Specific HTTP headers can be set for a request through one of the request builder's headers methods.

The methods of this class ( that accept a String header name ), and the Map returned by the map method, operate without regard to case when retrieving the header value(s).

An HTTP header name may appear more than once in the HTTP protocol. As such, headers are represented as a name and a list of values. Each occurrence of a header value is added verbatim, to the appropriate header name list, without interpreting its value. In particular, HttpHeaders does not perform any splitting or joining of comma separated header value strings. The order of elements in a header value list is preserved when building a request. For responses, the order of elements in a header value list is the order in which they were received. The Map returned by the map method, however, does not provide any guarantee with regard to the ordering of its entries.

HttpHeaders instances are immutable.

Since:
11