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.
Modifier and Type | Field and Description |
---|---|
private final Map | |
private static final HttpHeaders |
Access | Constructor and Description |
---|---|
private |
Modifier and Type | Method and Description |
---|---|
public List | |
private static final int | |
public final boolean | Returns: true if, and only if, the given object is an HttpHeaders that is equal to this HTTP headersthe object to which this object is to be compared obj)Overrides java. Tests this HTTP headers instance for equality with the given object. |
public Optional | Returns: anOptional<String> containing the first named header
string value, if presentthe header name name)Returns an |
public OptionalLong | Returns: anOptionalLong the header name name)Returns an |
public final int | Returns: the hash-code value for this HTTP headersOverrides java. Computes a hash code for this HTTP headers instance. |
private static HttpHeaders | |
public Map | |
public static HttpHeaders | Returns: an HTTP headers instance containing the given headersthe map containing the header names and values headerMap, BiPredicate<String, String> a filter that can be used to inspect each
header-name-and-value pair in the given map to determine if
it should, or should not, be added to the to the HTTP
headers filter)Returns an HTTP headers from the given map. |
public String | Returns: a string describing the HTTP headersOverrides java. Returns this HTTP headers as a string. |
headers | back to summary |
---|---|
private final Map<String, List<String>> headers |
NO_HEADERS | back to summary |
---|---|
private static final HttpHeaders NO_HEADERS |
HttpHeaders | back to summary |
---|---|
private HttpHeaders(Map<String, List<String>> headers) |
allValues | back to summary |
---|---|
public List Returns an unmodifiable List of all of the header string values of the given named header. Always returns a List, which may be empty if the header is not present. |
entryHash | back to summary |
---|---|
private static final int entryHash(Map. |
equals | back to summary |
---|---|
public final boolean equals(Object obj) Overrides java. Tests this HTTP headers instance for equality with the given object. If the given object is not an This method satisfies the general contract of the
|
firstValue | back to summary |
---|---|
public Optional Returns an |
firstValueAsLong | back to summary |
---|---|
public OptionalLong firstValueAsLong(String name) Returns an
|
hashCode | back to summary |
---|---|
public final int hashCode() Overrides java. Computes a hash code for this HTTP headers instance. The hash code is based upon the components of the HTTP headers
|
headersOf | back to summary |
---|---|
private static HttpHeaders headersOf(Map<String, List<String>> map, BiPredicate<String, String> filter) |
map | back to summary |
---|---|
public Map Returns an unmodifiable multi Map view of this HttpHeaders. |
of | back to summary |
---|---|
public static HttpHeaders of(Map<String, List<String>> headerMap, BiPredicate<String, String> filter) Returns an HTTP headers from the given map. The given map's key represents the header name, and its value the list of string header values for that header name. An HTTP header name may appear more than once in the HTTP protocol. Such, multi-valued, headers must be represented by a single entry in the given map, whose entry value is a list that represents the multiple header string values. Leading and trailing whitespaces are removed from all string values retrieved from the given map and its lists before processing. Only headers that, after filtering, contain at least one, possibly empty string, value will be added to the HTTP headers. API Note The primary purpose of this method is for testing frameworks.
Per-request headers can be set through one of the
|
toString | back to summary |
---|---|
public String toString() Overrides java. Returns this HTTP headers as a string. |