In addition to the regular methods defined by Map, this class offers many common
convenience methods, for example:
getFirst(String) returns the first value associated with a given header nameadd(String, String) adds a header value to the list of values for a header nameset(String, String) sets the header value to a single string valueNote that HttpHeaders generally treats header names in a case-insensitive manner.
| Modifier and Type | Field and Description |
|---|---|
| public static final String | ACCEPT
The HTTP |
| public static final String | ACCEPT_CHARSET
The HTTP |
| public static final String | ACCEPT_ENCODING
The HTTP |
| public static final String | ACCEPT_LANGUAGE
The HTTP |
| public static final String | ACCEPT_PATCH
The HTTP |
| public static final String | ACCEPT_RANGES
The HTTP |
| public static final String | ACCESS_CONTROL_ALLOW_CREDENTIALS
The CORS |
| public static final String | ACCESS_CONTROL_ALLOW_HEADERS
The CORS |
| public static final String | ACCESS_CONTROL_ALLOW_METHODS
The CORS |
| public static final String | ACCESS_CONTROL_ALLOW_ORIGIN
The CORS |
| public static final String | ACCESS_CONTROL_EXPOSE_HEADERS
The CORS |
| public static final String | ACCESS_CONTROL_MAX_AGE
The CORS |
| public static final String | ACCESS_CONTROL_REQUEST_HEADERS
The CORS |
| public static final String | ACCESS_CONTROL_REQUEST_METHOD
The CORS |
| public static final String | AGE
The HTTP |
| public static final String | ALLOW
The HTTP |
| public static final String | AUTHORIZATION
The HTTP |
| public static final String | CACHE_CONTROL
The HTTP |
| public static final String | CONNECTION
The HTTP |
| public static final String | CONTENT_DISPOSITION
The HTTP |
| public static final String | CONTENT_ENCODING
The HTTP |
| public static final String | CONTENT_LANGUAGE
The HTTP |
| public static final String | CONTENT_LENGTH
The HTTP |
| public static final String | CONTENT_LOCATION
The HTTP |
| public static final String | CONTENT_RANGE
The HTTP |
| public static final String | CONTENT_TYPE
The HTTP |
| public static final String | COOKIE
The HTTP |
| public static final String | DATE
The HTTP |
| private static final DateTimeFormatter | DATE_FORMATTER
Date formats with time zone as specified in the HTTP RFC to use for formatting. |
| private static final DateTimeFormatter[] | DATE_PARSERS
Date formats with time zone as specified in the HTTP RFC to use for parsing. |
| private static final DecimalFormatSymbols | |
| public static final HttpHeaders | EMPTY
An empty |
| public static final String | ETAG
The HTTP |
| private static final Pattern | ETAG_HEADER_VALUE_PATTERN
Pattern matching ETag multiple field values in headers such as "If-Match", "If-None-Match". |
| public static final String | EXPECT
The HTTP |
| public static final String | EXPIRES
The HTTP |
| public static final String | FROM
The HTTP |
| private static final ZoneId | |
| pack-priv final MultiValueMap | |
| public static final String | HOST
The HTTP |
| public static final String | IF_MATCH
The HTTP |
| public static final String | IF_MODIFIED_SINCE
The HTTP |
| public static final String | IF_NONE_MATCH
The HTTP |
| public static final String | IF_RANGE
The HTTP |
| public static final String | IF_UNMODIFIED_SINCE
The HTTP |
| public static final String | LAST_MODIFIED
The HTTP |
| public static final String | LINK
The HTTP |
| public static final String | LOCATION
The HTTP |
| public static final String | MAX_FORWARDS
The HTTP |
| public static final String | ORIGIN
The HTTP |
| public static final String | PRAGMA
The HTTP |
| public static final String | PROXY_AUTHENTICATE
The HTTP |
| public static final String | PROXY_AUTHORIZATION
The HTTP |
| public static final String | RANGE
The HTTP |
| public static final String | REFERER
The HTTP |
| public static final String | RETRY_AFTER
The HTTP |
| private static final long | |
| public static final String | SERVER
The HTTP |
| public static final String | SET_COOKIE
The HTTP |
| public static final String | SET_COOKIE2
The HTTP |
| public static final String | TE
The HTTP |
| public static final String | TRAILER
The HTTP |
| public static final String | TRANSFER_ENCODING
The HTTP |
| public static final String | UPGRADE
The HTTP |
| public static final String | USER_AGENT
The HTTP |
| public static final String | VARY
The HTTP |
| public static final String | VIA
The HTTP |
| public static final String | WARNING
The HTTP |
| public static final String | WWW_AUTHENTICATE
The HTTP |
| Access | Constructor and Description |
|---|---|
| public | |
| public | HttpHeaders(MultiValueMap<String, String>
the headers map (expected to operate with case-insensitive keys) headers)Construct a new |
| Modifier and Type | Method and Description |
|---|---|
| public void | add(String
the header name headerName, String the header value headerValue)Implements org. Add the given, single header value under the given name. |
| public void | addAll(String
they key key, List<? extends String> the values to be added values)Implements org. Add all the values of the given list to the current list of values for the given key. |
| public void | addAll(MultiValueMap<String, String>
the values to be added values)Implements org. Add all the values of the given |
| private static void | |
| public void | clear()
Implements java. Removes all of the mappings from this map (optional operation). |
| public void | |
| public boolean | containsKey(Object
key whose presence in this map is to be tested key)Implements java. Returns |
| public boolean | containsValue(Object
value whose presence in this map is to be tested value)Implements java. Returns |
| public static String | encodeBasicAuth(String
the username username, String the password password, Charset the charset to use to convert the credentials into an octet
sequence. Defaults to ISO-8859-1. charset)Encode the given username and password into Basic Authentication credentials. |
| public Set | entrySet()
Implements java. Returns a |
| public boolean | equals(Object
object to be compared for equality with this map other)Overrides java. Implements java. Compares the specified object with this map for equality. |
| public void | forEach(BiConsumer<? super String, ? super List<String>>
The action to be performed for each entry action)Overrides default java. Performs the given action for each entry in this map until all entries have been processed or the action throws an exception. |
| pack-priv static String | |
| public static String | Returns: the headers to a Stringthe headers to format headers)Helps to format HTTP header values, as HTTP header values themselves can
contain comma-separated values, can become confusing with regular
|
| public List | get(Object
the key whose associated value is to be returned key)Implements java. Returns the value to which the specified key is mapped,
or |
| public List | |
| public List | getAcceptCharset()
Return the list of acceptable charsets,
as specified by the |
| public List | |
| public List | Returns: the locales or an empty listA variant of |
| public List | getAcceptPatch()
Return the list of acceptable media types for
|
| public boolean | getAccessControlAllowCredentials()
Return the value of the |
| public List | |
| public List | |
| public String | |
| public List | getAccessControlExposeHeaders()
Return the value of the |
| public long | |
| public List | getAccessControlRequestHeaders()
Return the value of the |
| public HttpMethod | getAccessControlRequestMethod()
Return the value of the |
| public Set | |
| public String | |
| public List | |
| public ContentDisposition | |
| public Locale | Returns: the firstLocale of the content languages, or null
if unknownGet the first |
| public long | getContentLength()
Return the length of the body in bytes, as specified by the
|
| public MediaType | |
| public long | getDate()
Return the date and time at which the message was created, as specified
by the |
| public String | |
| protected List | Returns: the combined resultthe header name headerName)Retrieve a combined result from the field values of the ETag header. |
| public long | getExpires()
Return the date and time at which the message is no longer valid,
as specified by the |
| protected String | Returns: the combined resultthe header name headerName)Retrieve a combined result from the field values of multivalued headers. |
| public String | Returns: the first header value, ornull if nonethe header name headerName)Implements org. Return the first header value for the given header name, if any. |
| public long | Returns: the parsed date header, or -1 if nonethe header name headerName)Parse the first header value for the given header name as a date,
return -1 if there is no value, or raise |
| private long | Returns: the parsed date header, or -1 if none (or invalid)the header name headerName, boolean whether to reject invalid values with an
rejectInvalid)IllegalArgumentException (true) or rather return -1
in that case (false)Parse the first header value for the given header name as a date,
return -1 if there is no value or also in case of an invalid value
(if |
| public ZonedDateTime | Returns: the parsed date header, ornull if nonethe header name headerName)Parse the first header value for the given header name as a date,
return |
| private ZonedDateTime | Returns: the parsed date header, ornull if none (or invalid)the header name headerName, boolean whether to reject invalid values with an
rejectInvalid)IllegalArgumentException (true) or rather return null
in that case (false)Parse the first header value for the given header name as a date,
return |
| public InetSocketAddress | |
| public List | |
| public long | |
| public List | |
| public long | |
| public long | getLastModified()
Return the time the resource was last changed, as specified by the
|
| public URI | |
| public List | Returns: the list of header values, or an empty listthe header name headerName)Get the list of header values for the given header name, if any. |
| public String | |
| public String | |
| public List | |
| public String | |
| public List | Returns: all associated valuesthe header name headerName)Return all values of a given header name, even if this header is set multiple times. |
| public List | |
| public int | hashCode()
Overrides java. Implements java. Returns the hash code value for this map. |
| public boolean | |
| public Set | |
| public List | put(String
key with which the specified value is to be associated key, List<String> value to be associated with the specified key value)Implements java. Associates the specified value with the specified key in this map (optional operation). |
| public void | |
| public List | putIfAbsent(String
key with which the specified value is to be associated key, List<String> value to be associated with the specified key value)Overrides default java. If the specified key is not already associated with a value (or is mapped
to |
| public static HttpHeaders | Returns: a read-only variant of the headers, or the original headers as-is (in case it happens to be a read-onlyHttpHeaders instance already)the headers to expose headers)Apply a read-only |
| public static HttpHeaders | Returns: a read-only variant of the headers, or the original headers as-isthe headers to expose headers)Apply a read-only |
| public List | remove(Object
key whose mapping is to be removed from the map key)Implements java. Removes the mapping for a key from this map if it is present (optional operation). |
| public void | set(String
the header name headerName, String the header value headerValue)Implements org. Set the given, single header value under the given name. |
| public void | setAccept(List<MediaType> acceptableMediaTypes)
Set the list of acceptable media types,
as specified by the |
| public void | setAcceptCharset(List<Charset> acceptableCharsets)
Set the list of acceptable charsets,
as specified by the |
| public void | setAcceptLanguage(List<Locale.
Set the acceptable language ranges, as specified by the Accept-Language header. |
| public void | |
| public void | setAcceptPatch(List<MediaType> mediaTypes)
Set the list of acceptable media types for
|
| public void | setAccessControlAllowCredentials(boolean allowCredentials)
Set the (new) value of the |
| public void | setAccessControlAllowHeaders(List<String> allowedHeaders)
Set the (new) value of the |
| public void | setAccessControlAllowMethods(List<HttpMethod> allowedMethods)
Set the (new) value of the |
| public void | setAccessControlAllowOrigin(String allowedOrigin)
Set the (new) value of the |
| public void | setAccessControlExposeHeaders(List<String> exposedHeaders)
Set the (new) value of the |
| public void | setAccessControlMaxAge(Duration maxAge)
Set the (new) value of the |
| public void | setAccessControlMaxAge(long maxAge)
Set the (new) value of the |
| public void | setAccessControlRequestHeaders(List<String> requestHeaders)
Set the (new) value of the |
| public void | setAccessControlRequestMethod(HttpMethod requestMethod)
Set the (new) value of the |
| public void | setAll(Map<String, String>
the values. values)Implements org. Set the given values under. |
| public void | setAllow(Set<HttpMethod> allowedMethods)
Set the set of allowed |
| public void | setBasicAuth(String
the username username, String the password password)Set the value of the Authorization header to Basic Authentication based on the given username and password. |
| public void | setBasicAuth(String
the username username, String the password password, Charset the charset to use to convert the credentials into an octet
sequence. Defaults to ISO-8859-1. charset)Set the value of the Authorization header to Basic Authentication based on the given username and password. |
| public void | setBasicAuth(String
the encoded credentials encodedCredentials)Set the value of the Authorization header to Basic Authentication based on the given encoded credentials. |
| public void | setBearerAuth(String
the Base64 encoded token token)Set the value of the Authorization header to the given Bearer token. |
| public void | setCacheControl(CacheControl cacheControl)
Set a configured |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | setContentDispositionFormData(String
the control name name, String the filename (may be filename)null)Set the |
| public void | setContentLanguage(Locale locale)
Set the |
| public void | setContentLength(long contentLength)
Set the length of the body in bytes, as specified by the
|
| public void | setContentType(MediaType mediaType)
Set the media type of the body,
as specified by the |
| public void | setDate(ZonedDateTime date)
Set the date and time at which the message was created, as specified
by the |
| public void | |
| public void | setDate(long date)
Set the date and time at which the message was created, as specified
by the |
| public void | |
| public void | |
| public void | setExpires(ZonedDateTime expires)
Set the duration after which the message is no longer valid,
as specified by the |
| public void | setExpires(Instant expires)
Set the date and time at which the message is no longer valid,
as specified by the |
| public void | setExpires(long expires)
Set the date and time at which the message is no longer valid,
as specified by the |
| public void | |
| public void | |
| public void | |
| public void | setIfModifiedSince(ZonedDateTime ifModifiedSince)
Set the time the resource was last changed, as specified by the
|
| public void | setIfModifiedSince(Instant ifModifiedSince)
Set the time the resource was last changed, as specified by the
|
| public void | |
| public void | |
| public void | |
| public void | setIfUnmodifiedSince(ZonedDateTime ifUnmodifiedSince)
Set the time the resource was last changed, as specified by the
|
| public void | setIfUnmodifiedSince(Instant ifUnmodifiedSince)
Set the time the resource was last changed, as specified by the
|
| public void | |
| public void | setInstant(String headerName, Instant date)
Set the given date under the given header name after formatting it as a string using the RFC-1123 date-time formatter. |
| public void | setLastModified(ZonedDateTime lastModified)
Set the time the resource was last changed, as specified by the
|
| public void | setLastModified(Instant lastModified)
Set the time the resource was last changed, as specified by the
|
| public void | setLastModified(long lastModified)
Set the time the resource was last changed, as specified by the
|
| public void | |
| public void | |
| private void | setOrRemove(String
the header name headerName, String the header value, or headerValue)null for noneSet the given header value, or remove the header if |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | setZonedDateTime(String headerName, ZonedDateTime date)
Set the given date under the given header name after formatting it as a string using the RFC-1123 date-time formatter. |
| public int | |
| protected String | Returns: a combined result with comma delimitationthe list of header values headerValues)Turn the given list of header values into a comma-delimited result. |
| private static List | |
| public Map | toSingleValueMap()
Implements org. Return a |
| public String | |
| private static MultiValueMap | |
| public Collection | values()
Implements java. Returns a |
| public static HttpHeaders | Returns: a writable variant of the headers, or the original headers as-isthe headers to expose headers)Remove any read-only wrapper that may have been previously applied around
the given headers via |