public class HttpHeaders extends Object implements MultiValueMap<String,String>, Serializable
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 | 
|---|---|
| static String | ACCEPTThe HTTP  Acceptheader field name. | 
| static String | ACCEPT_CHARSETThe HTTP  Accept-Charsetheader field name. | 
| static String | ACCEPT_ENCODINGThe HTTP  Accept-Encodingheader field name. | 
| static String | ACCEPT_LANGUAGEThe HTTP  Accept-Languageheader field name. | 
| static String | ACCEPT_RANGESThe HTTP  Accept-Rangesheader field name. | 
| static String | ACCESS_CONTROL_ALLOW_CREDENTIALSThe CORS  Access-Control-Allow-Credentialsresponse header field name. | 
| static String | ACCESS_CONTROL_ALLOW_HEADERSThe CORS  Access-Control-Allow-Headersresponse header field name. | 
| static String | ACCESS_CONTROL_ALLOW_METHODSThe CORS  Access-Control-Allow-Methodsresponse header field name. | 
| static String | ACCESS_CONTROL_ALLOW_ORIGINThe CORS  Access-Control-Allow-Originresponse header field name. | 
| static String | ACCESS_CONTROL_EXPOSE_HEADERSThe CORS  Access-Control-Expose-Headersresponse header field name. | 
| static String | ACCESS_CONTROL_MAX_AGEThe CORS  Access-Control-Max-Ageresponse header field name. | 
| static String | ACCESS_CONTROL_REQUEST_HEADERSThe CORS  Access-Control-Request-Headersrequest header field name. | 
| static String | ACCESS_CONTROL_REQUEST_METHODThe CORS  Access-Control-Request-Methodrequest header field name. | 
| static String | AGEThe HTTP  Ageheader field name. | 
| static String | ALLOWThe HTTP  Allowheader field name. | 
| static String | AUTHORIZATIONThe HTTP  Authorizationheader field name. | 
| static String | CACHE_CONTROLThe HTTP  Cache-Controlheader field name. | 
| static String | CONNECTIONThe HTTP  Connectionheader field name. | 
| static String | CONTENT_DISPOSITIONThe HTTP  Content-Dispositionheader field name. | 
| static String | CONTENT_ENCODINGThe HTTP  Content-Encodingheader field name. | 
| static String | CONTENT_LANGUAGEThe HTTP  Content-Languageheader field name. | 
| static String | CONTENT_LENGTHThe HTTP  Content-Lengthheader field name. | 
| static String | CONTENT_LOCATIONThe HTTP  Content-Locationheader field name. | 
| static String | CONTENT_RANGEThe HTTP  Content-Rangeheader field name. | 
| static String | CONTENT_TYPEThe HTTP  Content-Typeheader field name. | 
| static String | COOKIEThe HTTP  Cookieheader field name. | 
| static String | DATEThe HTTP  Dateheader field name. | 
| static HttpHeaders | EMPTYAn empty  HttpHeadersinstance (immutable). | 
| static String | ETAGThe HTTP  ETagheader field name. | 
| static String | EXPECTThe HTTP  Expectheader field name. | 
| static String | EXPIRESThe HTTP  Expiresheader field name. | 
| static String | FROMThe HTTP  Fromheader field name. | 
| static String | HOSTThe HTTP  Hostheader field name. | 
| static String | IF_MATCHThe HTTP  If-Matchheader field name. | 
| static String | IF_MODIFIED_SINCEThe HTTP  If-Modified-Sinceheader field name. | 
| static String | IF_NONE_MATCHThe HTTP  If-None-Matchheader field name. | 
| static String | IF_RANGEThe HTTP  If-Rangeheader field name. | 
| static String | IF_UNMODIFIED_SINCEThe HTTP  If-Unmodified-Sinceheader field name. | 
| static String | LAST_MODIFIEDThe HTTP  Last-Modifiedheader field name. | 
| static String | LINKThe HTTP  Linkheader field name. | 
| static String | LOCATIONThe HTTP  Locationheader field name. | 
| static String | MAX_FORWARDSThe HTTP  Max-Forwardsheader field name. | 
| static String | ORIGINThe HTTP  Originheader field name. | 
| static String | PRAGMAThe HTTP  Pragmaheader field name. | 
| static String | PROXY_AUTHENTICATEThe HTTP  Proxy-Authenticateheader field name. | 
| static String | PROXY_AUTHORIZATIONThe HTTP  Proxy-Authorizationheader field name. | 
| static String | RANGEThe HTTP  Rangeheader field name. | 
| static String | REFERERThe HTTP  Refererheader field name. | 
| static String | RETRY_AFTERThe HTTP  Retry-Afterheader field name. | 
| static String | SERVERThe HTTP  Serverheader field name. | 
| static String | SET_COOKIEThe HTTP  Set-Cookieheader field name. | 
| static String | SET_COOKIE2The HTTP  Set-Cookie2header field name. | 
| static String | TEThe HTTP  TEheader field name. | 
| static String | TRAILERThe HTTP  Trailerheader field name. | 
| static String | TRANSFER_ENCODINGThe HTTP  Transfer-Encodingheader field name. | 
| static String | UPGRADEThe HTTP  Upgradeheader field name. | 
| static String | USER_AGENTThe HTTP  User-Agentheader field name. | 
| static String | VARYThe HTTP  Varyheader field name. | 
| static String | VIAThe HTTP  Viaheader field name. | 
| static String | WARNINGThe HTTP  Warningheader field name. | 
| static String | WWW_AUTHENTICATEThe HTTP  WWW-Authenticateheader field name. | 
| Constructor and Description | 
|---|
| HttpHeaders()Construct a new, empty instance of the  HttpHeadersobject. | 
| HttpHeaders(MultiValueMap<String,String> headers)Construct a new  HttpHeadersinstance backed by an existing map. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | add(String headerName,
   String headerValue)Add the given, single header value under the given name. | 
| void | addAll(MultiValueMap<String,String> values)Add all the values of the given  MultiValueMapto the current values. | 
| void | addAll(String key,
      List<? extends String> values)Add all the values of the given list to the current list of values for the given key. | 
| void | clear() | 
| void | clearContentHeaders()Remove the well-known  "Content-*"HTTP headers. | 
| boolean | containsKey(Object key) | 
| boolean | containsValue(Object value) | 
| static String | encodeBasicAuth(String username,
               String password,
               Charset charset)Encode the given username and password into Basic Authentication credentials. | 
| Set<Map.Entry<String,List<String>>> | entrySet() | 
| boolean | equals(Object other) | 
| static String | formatHeaders(MultiValueMap<String,String> headers)Helps to format HTTP header values, as HTTP header values themselves can
 contain comma-separated values, can become confusing with regular
  Mapformatting that also uses commas between entries. | 
| List<String> | get(Object key) | 
| List<MediaType> | getAccept()Return the list of acceptable media types,
 as specified by the  Acceptheader. | 
| List<Charset> | getAcceptCharset()Return the list of acceptable charsets,
 as specified by the  Accept-Charsetheader. | 
| List<Locale.LanguageRange> | getAcceptLanguage()Return the language ranges from the "Accept-Language" header. | 
| List<Locale> | getAcceptLanguageAsLocales() | 
| boolean | getAccessControlAllowCredentials()Return the value of the  Access-Control-Allow-Credentialsresponse header. | 
| List<String> | getAccessControlAllowHeaders()Return the value of the  Access-Control-Allow-Headersresponse header. | 
| List<HttpMethod> | getAccessControlAllowMethods()Return the value of the  Access-Control-Allow-Methodsresponse header. | 
| String | getAccessControlAllowOrigin()Return the value of the  Access-Control-Allow-Originresponse header. | 
| List<String> | getAccessControlExposeHeaders()Return the value of the  Access-Control-Expose-Headersresponse header. | 
| long | getAccessControlMaxAge()Return the value of the  Access-Control-Max-Ageresponse header. | 
| List<String> | getAccessControlRequestHeaders()Return the value of the  Access-Control-Request-Headersrequest header. | 
| HttpMethod | getAccessControlRequestMethod()Return the value of the  Access-Control-Request-Methodrequest header. | 
| Set<HttpMethod> | getAllow()Return the set of allowed  HTTP methods,
 as specified by theAllowheader. | 
| String | getCacheControl()Return the value of the  Cache-Controlheader. | 
| List<String> | getConnection()Return the value of the  Connectionheader. | 
| ContentDisposition | getContentDisposition()Return a parsed representation of the Content-Disposition header. | 
| Locale | getContentLanguage()Get the first  Localeof the content languages, as specified by theContent-Languageheader. | 
| long | getContentLength()Return the length of the body in bytes, as specified by the
  Content-Lengthheader. | 
| MediaType | getContentType()Return the media type of the body, as specified
 by the  Content-Typeheader. | 
| long | getDate()Return the date and time at which the message was created, as specified
 by the  Dateheader. | 
| String | getETag()Return the entity tag of the body, as specified by the  ETagheader. | 
| protected List<String> | getETagValuesAsList(String headerName)Retrieve a combined result from the field values of the ETag header. | 
| long | getExpires()Return the date and time at which the message is no longer valid,
 as specified by the  Expiresheader. | 
| protected String | getFieldValues(String headerName)Retrieve a combined result from the field values of multi-valued headers. | 
| String | getFirst(String headerName)Return the first header value for the given header name, if any. | 
| long | getFirstDate(String headerName)Parse the first header value for the given header name as a date,
 return -1 if there is no value, or raise  IllegalArgumentExceptionif the value cannot be parsed as a date. | 
| ZonedDateTime | getFirstZonedDateTime(String headerName)Parse the first header value for the given header name as a date,
 return  nullif there is no value, or raiseIllegalArgumentExceptionif the value cannot be parsed as a date. | 
| InetSocketAddress | getHost()Return the value of the  Hostheader, if available. | 
| List<String> | getIfMatch()Return the value of the  If-Matchheader. | 
| long | getIfModifiedSince()Return the value of the  If-Modified-Sinceheader. | 
| List<String> | getIfNoneMatch()Return the value of the  If-None-Matchheader. | 
| long | getIfUnmodifiedSince()Return the value of the  If-Unmodified-Sinceheader. | 
| long | getLastModified()Return the time the resource was last changed, as specified by the
  Last-Modifiedheader. | 
| URI | getLocation()Return the (new) location of a resource
 as specified by the  Locationheader. | 
| List<String> | getOrEmpty(Object headerName)Get the list of header values for the given header name, if any. | 
| String | getOrigin()Return the value of the  Originheader. | 
| String | getPragma()Return the value of the  Pragmaheader. | 
| List<HttpRange> | getRange()Return the value of the  Rangeheader. | 
| String | getUpgrade()Return the value of the  Upgradeheader. | 
| List<String> | getValuesAsList(String headerName)Return all values of a given header name,
 even if this header is set multiple times. | 
| List<String> | getVary()Return the request header names subject to content negotiation. | 
| int | hashCode() | 
| boolean | isEmpty() | 
| Set<String> | keySet() | 
| List<String> | put(String key,
   List<String> value) | 
| void | putAll(Map<? extends String,? extends List<String>> map) | 
| static HttpHeaders | readOnlyHttpHeaders(HttpHeaders headers)Apply a read-only  HttpHeaderswrapper around the given headers, if necessary. | 
| static HttpHeaders | readOnlyHttpHeaders(MultiValueMap<String,String> headers)Apply a read-only  HttpHeaderswrapper around the given headers, if necessary. | 
| List<String> | remove(Object key) | 
| void | set(String headerName,
   String headerValue)Set the given, single header value under the given name. | 
| void | setAccept(List<MediaType> acceptableMediaTypes)Set the list of acceptable media types,
 as specified by the  Acceptheader. | 
| void | setAcceptCharset(List<Charset> acceptableCharsets)Set the list of acceptable charsets,
 as specified by the  Accept-Charsetheader. | 
| void | setAcceptLanguage(List<Locale.LanguageRange> languages)Set the acceptable language ranges, as specified by the
 Accept-Language header. | 
| void | setAcceptLanguageAsLocales(List<Locale> locales)Variant of  setAcceptLanguage(List)usingLocale's. | 
| void | setAccessControlAllowCredentials(boolean allowCredentials)Set the (new) value of the  Access-Control-Allow-Credentialsresponse header. | 
| void | setAccessControlAllowHeaders(List<String> allowedHeaders)Set the (new) value of the  Access-Control-Allow-Headersresponse header. | 
| void | setAccessControlAllowMethods(List<HttpMethod> allowedMethods)Set the (new) value of the  Access-Control-Allow-Methodsresponse header. | 
| void | setAccessControlAllowOrigin(String allowedOrigin)Set the (new) value of the  Access-Control-Allow-Originresponse header. | 
| void | setAccessControlExposeHeaders(List<String> exposedHeaders)Set the (new) value of the  Access-Control-Expose-Headersresponse header. | 
| void | setAccessControlMaxAge(Duration maxAge)Set the (new) value of the  Access-Control-Max-Ageresponse header. | 
| void | setAccessControlMaxAge(long maxAge)Set the (new) value of the  Access-Control-Max-Ageresponse header. | 
| void | setAccessControlRequestHeaders(List<String> requestHeaders)Set the (new) value of the  Access-Control-Request-Headersrequest header. | 
| void | setAccessControlRequestMethod(HttpMethod requestMethod)Set the (new) value of the  Access-Control-Request-Methodrequest header. | 
| void | setAll(Map<String,String> values)Set the given values under. | 
| void | setAllow(Set<HttpMethod> allowedMethods)Set the set of allowed  HTTP methods,
 as specified by theAllowheader. | 
| void | setBasicAuth(String encodedCredentials)Set the value of the Authorization header to
 Basic Authentication based on the given encoded credentials. | 
| void | setBasicAuth(String username,
            String password)Set the value of the Authorization header to
 Basic Authentication based on the given username and password. | 
| void | setBasicAuth(String username,
            String password,
            Charset charset)Set the value of the Authorization header to
 Basic Authentication based on the given username and password. | 
| void | setBearerAuth(String token)Set the value of the Authorization header to
 the given Bearer token. | 
| void | setCacheControl(CacheControl cacheControl)Set a configured  CacheControlinstance as the
 new value of theCache-Controlheader. | 
| void | setCacheControl(String cacheControl)Set the (new) value of the  Cache-Controlheader. | 
| void | setConnection(List<String> connection)Set the (new) value of the  Connectionheader. | 
| void | setConnection(String connection)Set the (new) value of the  Connectionheader. | 
| void | setContentDisposition(ContentDisposition contentDisposition)Set the Content-Disposition header. | 
| void | setContentDispositionFormData(String name,
                             String filename)Set the  Content-Dispositionheader when creating a"multipart/form-data"request. | 
| void | setContentLanguage(Locale locale)Set the  Localeof the content language,
 as specified by the Content-Language header. | 
| void | setContentLength(long contentLength)Set the length of the body in bytes, as specified by the
  Content-Lengthheader. | 
| void | setContentType(MediaType mediaType)Set the media type of the body,
 as specified by the  Content-Typeheader. | 
| void | setDate(Instant date)Set the date and time at which the message was created, as specified
 by the  Dateheader. | 
| void | setDate(long date)Set the date and time at which the message was created, as specified
 by the  Dateheader. | 
| void | setDate(String headerName,
       long date)Set the given date under the given header name after formatting it as a string
 using the RFC-1123 date-time formatter. | 
| void | setDate(ZonedDateTime date)Set the date and time at which the message was created, as specified
 by the  Dateheader. | 
| void | setETag(String etag)Set the (new) entity tag of the body, as specified by the  ETagheader. | 
| void | setExpires(Instant expires)Set the date and time at which the message is no longer valid,
 as specified by the  Expiresheader. | 
| void | setExpires(long expires)Set the date and time at which the message is no longer valid,
 as specified by the  Expiresheader. | 
| void | setExpires(ZonedDateTime expires)Set the duration after which the message is no longer valid,
 as specified by the  Expiresheader. | 
| void | setHost(InetSocketAddress host)Set the (new) value of the  Hostheader. | 
| void | setIfMatch(List<String> ifMatchList)Set the (new) value of the  If-Matchheader. | 
| void | setIfMatch(String ifMatch)Set the (new) value of the  If-Matchheader. | 
| void | setIfModifiedSince(Instant ifModifiedSince)Set the time the resource was last changed, as specified by the
  Last-Modifiedheader. | 
| void | setIfModifiedSince(long ifModifiedSince)Set the (new) value of the  If-Modified-Sinceheader. | 
| void | setIfModifiedSince(ZonedDateTime ifModifiedSince)Set the time the resource was last changed, as specified by the
  Last-Modifiedheader. | 
| void | setIfNoneMatch(List<String> ifNoneMatchList)Set the (new) values of the  If-None-Matchheader. | 
| void | setIfNoneMatch(String ifNoneMatch)Set the (new) value of the  If-None-Matchheader. | 
| void | setIfUnmodifiedSince(Instant ifUnmodifiedSince)Set the time the resource was last changed, as specified by the
  Last-Modifiedheader. | 
| void | setIfUnmodifiedSince(long ifUnmodifiedSince)Set the (new) value of the  If-Unmodified-Sinceheader. | 
| void | setIfUnmodifiedSince(ZonedDateTime ifUnmodifiedSince)Set the time the resource was last changed, as specified by the
  Last-Modifiedheader. | 
| 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. | 
| void | setLastModified(Instant lastModified)Set the time the resource was last changed, as specified by the
  Last-Modifiedheader. | 
| void | setLastModified(long lastModified)Set the time the resource was last changed, as specified by the
  Last-Modifiedheader. | 
| void | setLastModified(ZonedDateTime lastModified)Set the time the resource was last changed, as specified by the
  Last-Modifiedheader. | 
| void | setLocation(URI location)Set the (new) location of a resource,
 as specified by the  Locationheader. | 
| void | setOrigin(String origin)Set the (new) value of the  Originheader. | 
| void | setPragma(String pragma)Set the (new) value of the  Pragmaheader. | 
| void | setRange(List<HttpRange> ranges)Sets the (new) value of the  Rangeheader. | 
| void | setUpgrade(String upgrade)Set the (new) value of the  Upgradeheader. | 
| void | setVary(List<String> requestHeaders)Set the request header names (e.g. | 
| 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. | 
| int | size() | 
| protected String | toCommaDelimitedString(List<String> headerValues)Turn the given list of header values into a comma-delimited result. | 
| Map<String,String> | toSingleValueMap()Return a  Mapwith the first values contained in thisMultiValueMap. | 
| String | toString() | 
| Collection<List<String>> | values() | 
| static HttpHeaders | writableHttpHeaders(HttpHeaders headers)Remove any read-only wrapper that may have been previously applied around
 the given headers via  readOnlyHttpHeaders(HttpHeaders). | 
clone, finalize, getClass, notify, notifyAll, wait, wait, waitaddIfAbsentcompute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAllpublic static final String ACCEPT
Accept header field name.public static final String ACCEPT_CHARSET
Accept-Charset header field name.public static final String ACCEPT_ENCODING
Accept-Encoding header field name.public static final String ACCEPT_LANGUAGE
Accept-Language header field name.public static final String ACCEPT_RANGES
Accept-Ranges header field name.public static final String ACCESS_CONTROL_ALLOW_CREDENTIALS
Access-Control-Allow-Credentials response header field name.public static final String ACCESS_CONTROL_ALLOW_HEADERS
Access-Control-Allow-Headers response header field name.public static final String ACCESS_CONTROL_ALLOW_METHODS
Access-Control-Allow-Methods response header field name.public static final String ACCESS_CONTROL_ALLOW_ORIGIN
Access-Control-Allow-Origin response header field name.public static final String ACCESS_CONTROL_EXPOSE_HEADERS
Access-Control-Expose-Headers response header field name.public static final String ACCESS_CONTROL_MAX_AGE
Access-Control-Max-Age response header field name.public static final String ACCESS_CONTROL_REQUEST_HEADERS
Access-Control-Request-Headers request header field name.public static final String ACCESS_CONTROL_REQUEST_METHOD
Access-Control-Request-Method request header field name.public static final String AGE
Age header field name.public static final String ALLOW
Allow header field name.public static final String AUTHORIZATION
Authorization header field name.public static final String CACHE_CONTROL
Cache-Control header field name.public static final String CONNECTION
Connection header field name.public static final String CONTENT_ENCODING
Content-Encoding header field name.public static final String CONTENT_DISPOSITION
Content-Disposition header field name.public static final String CONTENT_LANGUAGE
Content-Language header field name.public static final String CONTENT_LENGTH
Content-Length header field name.public static final String CONTENT_LOCATION
Content-Location header field name.public static final String CONTENT_RANGE
Content-Range header field name.public static final String CONTENT_TYPE
Content-Type header field name.public static final String COOKIE
Cookie header field name.public static final String DATE
Date header field name.public static final String ETAG
ETag header field name.public static final String EXPECT
Expect header field name.public static final String EXPIRES
Expires header field name.public static final String FROM
From header field name.public static final String HOST
Host header field name.public static final String IF_MATCH
If-Match header field name.public static final String IF_MODIFIED_SINCE
If-Modified-Since header field name.public static final String IF_NONE_MATCH
If-None-Match header field name.public static final String IF_RANGE
If-Range header field name.public static final String IF_UNMODIFIED_SINCE
If-Unmodified-Since header field name.public static final String LAST_MODIFIED
Last-Modified header field name.public static final String LINK
Link header field name.public static final String LOCATION
Location header field name.public static final String MAX_FORWARDS
Max-Forwards header field name.public static final String ORIGIN
Origin header field name.public static final String PRAGMA
Pragma header field name.public static final String PROXY_AUTHENTICATE
Proxy-Authenticate header field name.public static final String PROXY_AUTHORIZATION
Proxy-Authorization header field name.public static final String RANGE
Range header field name.public static final String REFERER
Referer header field name.public static final String RETRY_AFTER
Retry-After header field name.public static final String SERVER
Server header field name.public static final String SET_COOKIE
Set-Cookie header field name.public static final String SET_COOKIE2
Set-Cookie2 header field name.public static final String TE
TE header field name.public static final String TRAILER
Trailer header field name.public static final String TRANSFER_ENCODING
Transfer-Encoding header field name.public static final String UPGRADE
Upgrade header field name.public static final String USER_AGENT
User-Agent header field name.public static final String VARY
Vary header field name.public static final String VIA
Via header field name.public static final String WARNING
Warning header field name.public static final String WWW_AUTHENTICATE
WWW-Authenticate header field name.public static final HttpHeaders EMPTY
HttpHeaders instance (immutable).public HttpHeaders()
HttpHeaders object.
 This is the common constructor, using a case-insensitive map structure.
public HttpHeaders(MultiValueMap<String,String> headers)
HttpHeaders instance backed by an existing map.
 This constructor is available as an optimization for adapting to existing headers map structures, primarily for internal use within the framework.
headers - the headers map (expected to operate with case-insensitive keys)public List<String> getOrEmpty(Object headerName)
headerName - the header namepublic void setAccept(List<MediaType> acceptableMediaTypes)
Accept header.public List<MediaType> getAccept()
Accept header.
 Returns an empty list when the acceptable media types are unspecified.
public void setAcceptLanguage(List<Locale.LanguageRange> languages)
public List<Locale.LanguageRange> getAcceptLanguage()
If you only need sorted, preferred locales only use
 getAcceptLanguageAsLocales() or if you need to filter based on
 a list of supported locales you can pass the returned list to
 Locale.filter(List, Collection).
IllegalArgumentException - if the value cannot be converted to a language rangepublic void setAcceptLanguageAsLocales(List<Locale> locales)
setAcceptLanguage(List) using Locale's.public List<Locale> getAcceptLanguageAsLocales()
IllegalArgumentException - if the value cannot be converted to a localepublic void setAccessControlAllowCredentials(boolean allowCredentials)
Access-Control-Allow-Credentials response header.public boolean getAccessControlAllowCredentials()
Access-Control-Allow-Credentials response header.public void setAccessControlAllowHeaders(List<String> allowedHeaders)
Access-Control-Allow-Headers response header.public List<String> getAccessControlAllowHeaders()
Access-Control-Allow-Headers response header.public void setAccessControlAllowMethods(List<HttpMethod> allowedMethods)
Access-Control-Allow-Methods response header.public List<HttpMethod> getAccessControlAllowMethods()
Access-Control-Allow-Methods response header.public void setAccessControlAllowOrigin(@Nullable String allowedOrigin)
Access-Control-Allow-Origin response header.@Nullable public String getAccessControlAllowOrigin()
Access-Control-Allow-Origin response header.public void setAccessControlExposeHeaders(List<String> exposedHeaders)
Access-Control-Expose-Headers response header.public List<String> getAccessControlExposeHeaders()
Access-Control-Expose-Headers response header.public void setAccessControlMaxAge(Duration maxAge)
Access-Control-Max-Age response header.public void setAccessControlMaxAge(long maxAge)
Access-Control-Max-Age response header.public long getAccessControlMaxAge()
Access-Control-Max-Age response header.
 Returns -1 when the max age is unknown.
public void setAccessControlRequestHeaders(List<String> requestHeaders)
Access-Control-Request-Headers request header.public List<String> getAccessControlRequestHeaders()
Access-Control-Request-Headers request header.public void setAccessControlRequestMethod(@Nullable HttpMethod requestMethod)
Access-Control-Request-Method request header.@Nullable public HttpMethod getAccessControlRequestMethod()
Access-Control-Request-Method request header.public void setAcceptCharset(List<Charset> acceptableCharsets)
Accept-Charset header.public List<Charset> getAcceptCharset()
Accept-Charset header.public void setAllow(Set<HttpMethod> allowedMethods)
HTTP methods,
 as specified by the Allow header.public Set<HttpMethod> getAllow()
HTTP methods,
 as specified by the Allow header.
 Returns an empty set when the allowed methods are unspecified.
public void setBasicAuth(String username, String password)
Note that this method only supports characters in the
 ISO-8859-1 character set.
username - the usernamepassword - the passwordIllegalArgumentException - if either user or
 password contain characters that cannot be encoded to ISO-8859-1setBasicAuth(String), 
setBasicAuth(String, String, Charset), 
encodeBasicAuth(String, String, Charset), 
RFC 7617public void setBasicAuth(String username, String password, @Nullable Charset charset)
username - the usernamepassword - the passwordcharset - the charset to use to convert the credentials into an octet
 sequence. Defaults to ISO-8859-1.IllegalArgumentException - if username or password
 contains characters that cannot be encoded to the given charsetsetBasicAuth(String), 
setBasicAuth(String, String), 
encodeBasicAuth(String, String, Charset), 
RFC 7617public void setBasicAuth(String encodedCredentials)
Favor this method over setBasicAuth(String, String) and
 setBasicAuth(String, String, Charset) if you wish to cache the
 encoded credentials.
encodedCredentials - the encoded credentialsIllegalArgumentException - if supplied credentials string is
 null or blanksetBasicAuth(String, String), 
setBasicAuth(String, String, Charset), 
encodeBasicAuth(String, String, Charset), 
RFC 7617public void setBearerAuth(String token)
token - the Base64 encoded tokenpublic void setCacheControl(CacheControl cacheControl)
CacheControl instance as the
 new value of the Cache-Control header.public void setCacheControl(@Nullable String cacheControl)
Cache-Control header.@Nullable public String getCacheControl()
Cache-Control header.public void setConnection(String connection)
Connection header.public void setConnection(List<String> connection)
Connection header.public void setContentDispositionFormData(String name, @Nullable String filename)
Content-Disposition header when creating a
 "multipart/form-data" request.
 Applications typically would not set this header directly but
 rather prepare a MultiValueMap<String, Object>, containing an
 Object or a Resource for each part,
 and then pass that to the RestTemplate or WebClient.
name - the control namefilename - the filename (may be null)getContentDisposition()public void setContentDisposition(ContentDisposition contentDisposition)
This could be used on a response to indicate if the content is expected to be displayed inline in the browser or as an attachment to be saved locally.
It can also be used for a "multipart/form-data" request.
 For more details see notes on setContentDispositionFormData(java.lang.String, java.lang.String).
getContentDisposition()public ContentDisposition getContentDisposition()
setContentDisposition(ContentDisposition)public void setContentLanguage(@Nullable Locale locale)
Locale of the content language,
 as specified by the Content-Language header.
 Use put(CONTENT_LANGUAGE, list) if you need
 to set multiple content languages.
@Nullable public Locale getContentLanguage()
Locale of the content languages, as specified by the
 Content-Language header.
 Use getValuesAsList(String) if you need to get multiple content
 languages.
Locale of the content languages, or null
 if unknownpublic void setContentLength(long contentLength)
Content-Length header.public long getContentLength()
Content-Length header.
 Returns -1 when the content-length is unknown.
public void setContentType(@Nullable MediaType mediaType)
Content-Type header.@Nullable public MediaType getContentType()
Content-Type header.
 Returns null when the content-type is unknown.
public void setDate(ZonedDateTime date)
Date header.public void setDate(Instant date)
Date header.public void setDate(long date)
Date header.
 The date should be specified as the number of milliseconds since January 1, 1970 GMT.
public long getDate()
Date header.
 The date is returned as the number of milliseconds since January 1, 1970 GMT. Returns -1 when the date is unknown.
IllegalArgumentException - if the value cannot be converted to a datepublic void setETag(@Nullable String etag)
ETag header.@Nullable public String getETag()
ETag header.public void setExpires(ZonedDateTime expires)
Expires header.public void setExpires(Instant expires)
Expires header.public void setExpires(long expires)
Expires header.
 The date should be specified as the number of milliseconds since January 1, 1970 GMT.
public long getExpires()
Expires header.
 The date is returned as the number of milliseconds since January 1, 1970 GMT. Returns -1 when the date is unknown.
getFirstZonedDateTime(String)public void setHost(@Nullable InetSocketAddress host)
Host header.
 If the given port is 0,
 the host header will only contain the
 host name.
@Nullable public InetSocketAddress getHost()
Host header, if available.
 If the header value does not contain a port, the
 port in the returned address will
 be 0.
public void setIfMatch(String ifMatch)
If-Match header.public void setIfMatch(List<String> ifMatchList)
If-Match header.public List<String> getIfMatch()
If-Match header.IllegalArgumentException - if parsing failspublic void setIfModifiedSince(ZonedDateTime ifModifiedSince)
Last-Modified header.public void setIfModifiedSince(Instant ifModifiedSince)
Last-Modified header.public void setIfModifiedSince(long ifModifiedSince)
If-Modified-Since header.
 The date should be specified as the number of milliseconds since January 1, 1970 GMT.
public long getIfModifiedSince()
If-Modified-Since header.
 The date is returned as the number of milliseconds since January 1, 1970 GMT. Returns -1 when the date is unknown.
getFirstZonedDateTime(String)public void setIfNoneMatch(String ifNoneMatch)
If-None-Match header.public void setIfNoneMatch(List<String> ifNoneMatchList)
If-None-Match header.public List<String> getIfNoneMatch()
If-None-Match header.IllegalArgumentException - if parsing failspublic void setIfUnmodifiedSince(ZonedDateTime ifUnmodifiedSince)
Last-Modified header.public void setIfUnmodifiedSince(Instant ifUnmodifiedSince)
Last-Modified header.public void setIfUnmodifiedSince(long ifUnmodifiedSince)
If-Unmodified-Since header.
 The date should be specified as the number of milliseconds since January 1, 1970 GMT.
public long getIfUnmodifiedSince()
If-Unmodified-Since header.
 The date is returned as the number of milliseconds since January 1, 1970 GMT. Returns -1 when the date is unknown.
getFirstZonedDateTime(String)public void setLastModified(ZonedDateTime lastModified)
Last-Modified header.public void setLastModified(Instant lastModified)
Last-Modified header.public void setLastModified(long lastModified)
Last-Modified header.
 The date should be specified as the number of milliseconds since January 1, 1970 GMT.
public long getLastModified()
Last-Modified header.
 The date is returned as the number of milliseconds since January 1, 1970 GMT. Returns -1 when the date is unknown.
getFirstZonedDateTime(String)public void setLocation(@Nullable URI location)
Location header.@Nullable public URI getLocation()
Location header.
 Returns null when the location is unknown.
public List<HttpRange> getRange()
Range header.
 Returns an empty list when the range is unknown.
public void setUpgrade(@Nullable String upgrade)
Upgrade header.public void setVary(List<String> requestHeaders)
requestHeaders - the request header namespublic List<String> getVary()
public void setZonedDateTime(String headerName, ZonedDateTime date)
set(String, String) but for date headers.public void setInstant(String headerName, Instant date)
set(String, String) but for date headers.public void setDate(String headerName, long date)
set(String, String) but for date headers.setZonedDateTime(String, ZonedDateTime)public long getFirstDate(String headerName)
IllegalArgumentException
 if the value cannot be parsed as a date.headerName - the header namegetFirstZonedDateTime(String)@Nullable public ZonedDateTime getFirstZonedDateTime(String headerName)
null if there is no value, or raise IllegalArgumentException
 if the value cannot be parsed as a date.headerName - the header namenull if nonepublic List<String> getValuesAsList(String headerName)
headerName - the header namepublic void clearContentHeaders()
"Content-*" HTTP headers.
 Such headers should be cleared from the response if the intended body can't be written due to errors.
protected List<String> getETagValuesAsList(String headerName)
headerName - the header nameIllegalArgumentException - if parsing fails@Nullable protected String getFieldValues(String headerName)
headerName - the header nameprotected String toCommaDelimitedString(List<String> headerValues)
headerValues - the list of header values@Nullable public String getFirst(String headerName)
getFirst in interface MultiValueMap<String,String>headerName - the header namenull if nonepublic void add(String headerName, @Nullable String headerValue)
add in interface MultiValueMap<String,String>headerName - the header nameheaderValue - the header valueUnsupportedOperationException - if adding headers is not supportedput(String, List), 
set(String, String)public void addAll(String key, List<? extends String> values)
MultiValueMapaddAll in interface MultiValueMap<String,String>key - they keyvalues - the values to be addedpublic void addAll(MultiValueMap<String,String> values)
MultiValueMapMultiValueMap to the current values.addAll in interface MultiValueMap<String,String>values - the values to be addedpublic void set(String headerName, @Nullable String headerValue)
set in interface MultiValueMap<String,String>headerName - the header nameheaderValue - the header valueUnsupportedOperationException - if adding headers is not supportedput(String, List), 
add(String, String)public void setAll(Map<String,String> values)
MultiValueMapsetAll in interface MultiValueMap<String,String>values - the values.public Map<String,String> toSingleValueMap()
MultiValueMapMap with the first values contained in this MultiValueMap.toSingleValueMap in interface MultiValueMap<String,String>public boolean containsKey(Object key)
containsKey in interface Map<String,List<String>>public boolean containsValue(Object value)
containsValue in interface Map<String,List<String>>public Collection<List<String>> values()
public int hashCode()
public static HttpHeaders readOnlyHttpHeaders(MultiValueMap<String,String> headers)
HttpHeaders wrapper around the given headers, if necessary.
 Also caches the parsed representations of the "Accept" and "Content-Type" headers.
headers - the headers to exposeHttpHeaders instance already)public static HttpHeaders readOnlyHttpHeaders(HttpHeaders headers)
HttpHeaders wrapper around the given headers, if necessary.
 Also caches the parsed representations of the "Accept" and "Content-Type" headers.
headers - the headers to exposepublic static HttpHeaders writableHttpHeaders(HttpHeaders headers)
readOnlyHttpHeaders(HttpHeaders).headers - the headers to exposepublic static String formatHeaders(MultiValueMap<String,String> headers)
Map formatting that also uses commas between entries.headers - the headers to formatpublic static String encodeBasicAuth(String username, String password, @Nullable Charset charset)
The encoded credentials returned by this method can be supplied to
 setBasicAuth(String) to set the Basic Authentication header.
username - the usernamepassword - the passwordcharset - the charset to use to convert the credentials into an octet
 sequence. Defaults to ISO-8859-1.IllegalArgumentException - if username or password
 contains characters that cannot be encoded to the given charsetsetBasicAuth(String), 
setBasicAuth(String, String), 
setBasicAuth(String, String, Charset), 
RFC 7617