类 HttpHeaders
- 直接已知子类:
DefaultHttpHeaders
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 value
Note that HttpHeaders generally treats header names in a case-insensitive manner.
- 从以下版本开始:
- 3.0 2020-01-28 17:15
- 作者:
- Arjen Poutsma, Sebastien Deleuze, Brian Clozel, Juergen Hoeller, Josh Long, Sam Brannen, Harry Yang
- 另请参阅:
-
嵌套类概要
-
字段概要
字段修饰符和类型字段说明static final StringThe HTTPAcceptheader field name.static final StringThe HTTPAccept-Charsetheader field name.static final StringThe HTTPAccept-Encodingheader field name.static final StringThe HTTPAccept-Languageheader field name.static final StringThe HTTPAccept-Patchheader field name.static final StringThe HTTPAccept-Rangesheader field name.static final StringThe CORSAccess-Control-Allow-Credentialsresponse header field name.static final StringThe CORSAccess-Control-Allow-Headersresponse header field name.static final StringThe CORSAccess-Control-Allow-Methodsresponse header field name.static final StringThe CORSAccess-Control-Allow-Originresponse header field name.static final StringThe CORSAccess-Control-Expose-Headersresponse header field name.static final StringThe CORSAccess-Control-Max-Ageresponse header field name.static final StringThe CORSAccess-Control-Request-Headersrequest header field name.static final StringThe CORSAccess-Control-Request-Methodrequest header field name.static final StringThe HTTPAgeheader field name.static final StringThe HTTPAllowheader field name.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringThe HTTPAuthorizationheader field name.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringThe HTTPCache-Controlheader field name.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringThe HTTPConnectionheader field name.static final StringThe HTTPContent-Dispositionheader field name.static final StringThe HTTPContent-Encodingheader field name.static final StringThe HTTPContent-Languageheader field name.static final StringThe HTTPContent-Lengthheader field name.static final StringThe HTTPContent-Locationheader field name.static final StringThe HTTPContent-Rangeheader field name.static final Stringstatic final StringThe HTTPContent-Typeheader field name.static final Stringstatic final StringThe HTTPCookieheader field name.static final StringThe HTTPDateheader field name.static final DateTimeFormatterDate formats with time zone as specified in the HTTP RFC to use for formatting.static final DateTimeFormatter[]Date formats with time zone as specified in the HTTP RFC to use for parsing.static final DecimalFormatSymbolsstatic final Stringstatic final StringThe HTTPETagheader field name.static final PatternPattern matching ETag multiple field values in headers such as "If-Match", "If-None-Match".static final StringThe HTTPExpectheader field name.static final StringThe HTTPExpiresheader field name.static final StringThe HTTPFromheader field name.static final ZoneIdstatic final Stringstatic final Stringstatic final StringThe HTTPHostheader field name.static final Stringstatic final StringThe HTTPIf-Matchheader field name.static final StringThe HTTPIf-Modified-Sinceheader field name.static final StringThe HTTPIf-None-Matchheader field name.static final StringThe HTTPIf-Rangeheader field name.static final StringThe HTTPIf-Unmodified-Sinceheader field name.static final Stringstatic final Stringstatic final StringThe HTTPLast-Modifiedheader field name.static final StringThe HTTPLinkheader field name.static final StringThe HTTPLocationheader field name.static final Stringstatic final StringThe HTTPMax-Forwardsheader field name.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringThe HTTPOriginheader field name.static final StringThe HTTPPragmaheader field name.static final Stringstatic final StringThe HTTPProxy-Authenticateheader field name.static final StringThe HTTPProxy-Authorizationheader field name.static final Stringstatic final Stringstatic final Stringstatic final StringThe HTTPRangeheader field name.static final StringThe HTTPRefererheader field name.static final StringThe HTTPRetry-Afterheader field name.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprivate static final longstatic final StringThe HTTPServerheader field name.static final StringThe HTTPSet-Cookieheader field name.static final StringThe HTTPSet-Cookie2header field name.static final StringThe HTTPTEheader field name.static final StringThe HTTPTrailerheader field name.static final Stringstatic final StringThe HTTPTransfer-Encodingheader field name.static final StringThe HTTPUpgradeheader field name.static final StringThe HTTPUser-Agentheader field name.static final StringThe HTTPVaryheader field name.static final StringThe HTTPViaheader field name.static final StringThe HTTPWarningheader field name.static final Stringstatic final Stringstatic final Stringstatic final StringThe HTTPWWW-Authenticateheader field name.static final Stringstatic final String从接口继承的字段 cn.taketoday.util.MultiValueMap
defaultMappingFunction -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明abstract voidAdd the given, single header value under the given name.private static voidaddToken(StringBuilder builder, List<String> tokens, boolean trim) voidRemove the well-known"Content-*"HTTP headers.static HttpHeaderscopy targetMap’s all entries to a new HttpHeadersstatic DefaultHttpHeaderscreate()static HttpHeadersempty()static StringencodeBasicAuth(String username, String password, Charset charset) Encode the given username and password into Basic Authentication credentials.(专用程序包) static StringformatDate(long date) static StringformatHeaders(cn.taketoday.util.MultiValueMap<String, String> headers) Helps to format HTTP header values, as HTTP header values themselves can contain comma-separated values, can become confusing with regularMapformatting that also uses commas between entries.static DefaultHttpHeadersConstruct a newHttpHeadersinstance backed by an existing map.Return the list of acceptable media types, as specified by theAcceptheader.Return the list of acceptable charsets, as specified by theAccept-Charsetheader.Return the language ranges from the "Accept-Language" header.Return the list of acceptable media types forPATCHmethods, as specified by theAccept-Patchheader.booleanReturn the value of theAccess-Control-Allow-Credentialsresponse header.Return the value of theAccess-Control-Allow-Headersresponse header.Return the value of theAccess-Control-Allow-Methodsresponse header.Return the value of theAccess-Control-Allow-Originresponse header.Return the value of theAccess-Control-Expose-Headersresponse header.longReturn the value of theAccess-Control-Max-Ageresponse header.Return the value of theAccess-Control-Request-Headersrequest header.Return the value of theAccess-Control-Request-Methodrequest header.getAllow()Return the set of allowedHTTP methods, as specified by theAllowheader.Return the value of theCache-Controlheader.Return the value of theConnectionheader.Return a parsed representation of the Content-Disposition header.Return the firstLocaleof the content languages, as specified by the Content-Language header.longReturn the length of the body in bytes, as specified by theContent-Lengthheader.Return the media type of the body, as specified by theContent-Typeheader.longgetDate()Return the date and time at which the message was created, as specified by theDateheader.getETag()Return the entity tag of the body, as specified by theETagheader.getETagValuesAsList(String headerName) Retrieve a combined result from the field values of the ETag header.longReturn the date and time at which the message is no longer valid, as specified by theExpiresheader.getFieldValues(String headerName) Retrieve a combined result from the field values of multi-valued headers.abstract StringReturn the first header value for the given header name, if any.longgetFirstDate(String headerName) Parse the first header value for the given header name as a date, return -1 if there is no value, or raiseIllegalArgumentExceptionif the value cannot be parsed as a date.longgetFirstDate(String headerName, boolean rejectInvalid) 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 (ifrejectInvalid=false), or raiseIllegalArgumentExceptionif the value cannot be parsed as a date.getFirstZonedDateTime(String headerName) Parse the first header value for the given header name as a date, returnnullif there is no value, or raiseIllegalArgumentExceptionif the value cannot be parsed as a date.getFirstZonedDateTime(String headerName, boolean rejectInvalid) Parse the first header value for the given header name as a date, returnnullif there is no value or also in case of an invalid value (ifrejectInvalid=false), or raiseIllegalArgumentExceptionif the value cannot be parsed as a date.getHost()Return the value of theHostheader, if available.Return the value of theIf-Matchheader.longReturn the value of theIf-Modified-Sinceheader.Return the value of theIf-None-Matchheader.longReturn the value of theIf-Unmodified-Sinceheader.longReturn the time the resource was last changed, as specified by theLast-Modifiedheader.Return the (new) location of a resource as specified by theLocationheader.getOrEmpty(String headerName) Get the list of header values for the given header name, if any.Return the value of theOriginheader.Return the value of thePragmaheader.getRange()Return the value of theRangeheader.Return the value of theUpgradeheader.getValuesAsList(String headerName) Return all values of a given header name, even if this header is set multiple times.getVary()Return the request header names subject to content negotiation.static HttpHeadersreadOnlyHttpHeaders(HttpHeaders headers) Apply a read-onlyHttpHeaderswrapper around the given headers, if necessary.static HttpHeadersreadOnlyHttpHeaders(cn.taketoday.util.MultiValueMap<String, String> headers) Apply a read-onlyHttpHeaderswrapper around the given headers, if necessary.abstract voidvoidsetAccept(Collection<MediaType> acceptableMediaTypes) Set the list of acceptable media types, as specified by theAcceptheader.voidsetAcceptCharset(Collection<Charset> acceptableCharsets) Set the list of acceptable charsets, as specified by theAccept-Charsetheader.voidsetAcceptLanguage(Collection<Locale.LanguageRange> languages) Set the acceptable language ranges, as specified by the Accept-Language header.voidsetAcceptLanguageAsLocales(Collection<Locale> locales) Variant ofsetAcceptLanguage(Collection)usingLocale's.voidsetAcceptPatch(Collection<MediaType> mediaTypes) voidsetAccessControlAllowCredentials(boolean allowCredentials) Set the (new) value of theAccess-Control-Allow-Credentialsresponse header.voidsetAccessControlAllowHeaders(Collection<String> allowedHeaders) Set the (new) value of theAccess-Control-Allow-Headersresponse header.voidsetAccessControlAllowMethods(Collection<?> allowedMethods) Set the (new) value of theAccess-Control-Allow-Methodsresponse header.voidsetAccessControlAllowOrigin(String allowedOrigin) Set the (new) value of theAccess-Control-Allow-Originresponse header.voidsetAccessControlExposeHeaders(Collection<String> exposedHeaders) Set the (new) value of theAccess-Control-Expose-Headersresponse header.voidsetAccessControlMaxAge(long maxAge) Set the (new) value of theAccess-Control-Max-Ageresponse header.voidsetAccessControlMaxAge(Duration maxAge) Set the (new) value of theAccess-Control-Max-Ageresponse header.voidsetAccessControlRequestHeaders(Collection<String> requestHeaders) Set the (new) value of theAccess-Control-Request-Headersrequest header.voidsetAccessControlRequestMethod(HttpMethod requestMethod) Set the (new) value of theAccess-Control-Request-Methodrequest header.voidsetAllow(HttpMethod... allowedMethods) Set the set of allowedHTTP methods, as specified by theAllowheader.voidSet the set of allowedHTTP methods, as specified by theAllowheader.voidsetAllow(Collection<HttpMethod> allowedMethods) Set the set of allowedHTTP methods, as specified by theAllowheader.voidsetBasicAuth(String encodedCredentials) Set the value of the Authorization header to Basic AuthenticationvoidsetBasicAuth(String username, String password) Set the value of the Authorization header to Basic Authentication based on the given username and password.voidsetBasicAuth(String username, String password, Charset charset) Set the value of the Authorization header to Basic Authentication based on the given username and password.voidsetBearerAuth(String token) Set the value of the Authorization header to the given Bearer token.voidsetCacheControl(CacheControl cacheControl) Set a configuredCacheControlinstance as the new value of theCache-Controlheader.voidsetCacheControl(String cacheControl) Set the (new) value of theCache-Controlheader.voidsetConnection(String connection) Set the (new) value of theConnectionheader.voidsetConnection(Collection<String> connection) Set the (new) value of theConnectionheader.voidsetContentDisposition(ContentDisposition contentDisposition) Set the Content-Disposition header.voidsetContentDisposition(String contentDisposition) voidsetContentDispositionFormData(String name, String filename) Set theContent-Dispositionheader when creating a"multipart/form-data"request.voidsetContentLanguage(Locale locale) Set theLocaleof the content language, as specified by the Content-Language header.voidsetContentLength(long contentLength) Set the length of the body in bytes, as specified by theContent-Lengthheader.voidsetContentType(MediaType mediaType) Set the media type of the body, as specified by theContent-Typeheader.voidsetDate(long date) Set the date and time at which the message was created, as specified by theDateheader.voidSet the given date under the given header name after formatting it as a string using the RFC-1123 date-time formatter.voidSet the date and time at which the message was created, as specified by theDateheader.voidsetDate(ZonedDateTime date) Set the date and time at which the message was created, as specified by theDateheader.voidSet the (new) entity tag of the body, as specified by theETagheader.voidsetExpires(long expires) Set the date and time at which the message is no longer valid, as specified by theExpiresheader.voidsetExpires(Instant expires) Set the date and time at which the message is no longer valid, as specified by theExpiresheader.voidsetExpires(ZonedDateTime expires) Set the duration after which the message is no longer valid, as specified by theExpiresheader.voidsetHost(InetSocketAddress host) Set the (new) value of theHostheader.voidsetIfMatch(String ifMatch) Set the (new) value of theIf-Matchheader.voidsetIfMatch(Collection<String> ifMatchList) Set the (new) value of theIf-Matchheader.voidsetIfModifiedSince(long ifModifiedSince) Set the (new) value of theIf-Modified-Sinceheader.voidsetIfModifiedSince(Instant ifModifiedSince) Set the time the resource was last changed, as specified by theLast-Modifiedheader.voidsetIfModifiedSince(ZonedDateTime ifModifiedSince) Set the time the resource was last changed, as specified by theLast-Modifiedheader.voidsetIfNoneMatch(String ifNoneMatch) Set the (new) value of theIf-None-Matchheader.voidsetIfNoneMatch(Collection<String> ifNoneMatchList) Set the (new) values of theIf-None-Matchheader.voidsetIfUnmodifiedSince(long ifUnmodifiedSince) Set the (new) value of theIf-Unmodified-Sinceheader.voidsetIfUnmodifiedSince(Instant ifUnmodifiedSince) Set the time the resource was last changed, as specified by theLast-Modifiedheader.voidsetIfUnmodifiedSince(ZonedDateTime ifUnmodifiedSince) Set the time the resource was last changed, as specified by theLast-Modifiedheader.voidsetInstant(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.voidsetLastModified(long lastModified) Set the time the resource was last changed, as specified by theLast-Modifiedheader.voidsetLastModified(Instant lastModified) Set the time the resource was last changed, as specified by theLast-Modifiedheader.voidsetLastModified(ZonedDateTime lastModified) Set the time the resource was last changed, as specified by theLast-Modifiedheader.voidsetLocation(String location) Set the (new) location of a resource, as specified by theLocationheader.voidsetLocation(URI location) Set the (new) location of a resource, as specified by theLocationheader.voidSet the (new) value of theOriginheader.voidsetOrRemove(String headerName, String headerValue) Set the given header value, or remove the header ifnull.voidSet the (new) value of thePragmaheader.voidsetRange(Collection<HttpRange> ranges) Sets the (new) value of theRangeheader.voidsetUpgrade(String upgrade) Set the (new) value of theUpgradeheader.voidSet the request header names (e.g.voidsetVary(Collection<String> requestHeaders) Set the request header names (e.g.voidsetZonedDateTime(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.protected StringtoCommaDelimitedString(Collection<?> headerValues) Turn the given list of header values into a comma-delimited result.tokenizeQuoted(String str) toString()static HttpHeaderswritableHttpHeaders(HttpHeaders headers) Remove any read-only wrapper that may have been previously applied around the given headers viareadOnlyHttpHeaders(HttpHeaders).从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait从接口继承的方法 java.util.Map
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, replace, replace, replaceAll, size, values从接口继承的方法 cn.taketoday.util.MultiValueMap
addAll, addAll, addAll, addAll, addIfAbsent, copyToArrayMap, setAll, toArrayMap, toSingleValueMap
-
字段详细资料
-
serialVersionUID
private static final long serialVersionUID- 另请参阅:
-
ACCEPT
The HTTPAcceptheader field name. -
ACCEPT_CHARSET
The HTTPAccept-Charsetheader field name. -
ACCEPT_ENCODING
The HTTPAccept-Encodingheader field name. -
ACCEPT_LANGUAGE
The HTTPAccept-Languageheader field name. -
ACCEPT_PATCH
The HTTPAccept-Patchheader field name.- 另请参阅:
-
ACCEPT_RANGES
The HTTPAccept-Rangesheader field name. -
ACCESS_CONTROL_ALLOW_CREDENTIALS
The CORSAccess-Control-Allow-Credentialsresponse header field name.- 另请参阅:
-
ACCESS_CONTROL_ALLOW_HEADERS
The CORSAccess-Control-Allow-Headersresponse header field name.- 另请参阅:
-
ACCESS_CONTROL_ALLOW_METHODS
The CORSAccess-Control-Allow-Methodsresponse header field name.- 另请参阅:
-
ACCESS_CONTROL_ALLOW_ORIGIN
The CORSAccess-Control-Allow-Originresponse header field name.- 另请参阅:
-
ACCESS_CONTROL_EXPOSE_HEADERS
The CORSAccess-Control-Expose-Headersresponse header field name.- 另请参阅:
-
ACCESS_CONTROL_MAX_AGE
The CORSAccess-Control-Max-Ageresponse header field name.- 另请参阅:
-
ACCESS_CONTROL_REQUEST_HEADERS
The CORSAccess-Control-Request-Headersrequest header field name.- 另请参阅:
-
ACCESS_CONTROL_REQUEST_METHOD
The CORSAccess-Control-Request-Methodrequest header field name.- 另请参阅:
-
AGE
The HTTPAgeheader field name.- 另请参阅:
-
ALLOW
The HTTPAllowheader field name. -
AUTHORIZATION
The HTTPAuthorizationheader field name.- 另请参阅:
-
CACHE_CONTROL
The HTTPCache-Controlheader field name.- 另请参阅:
-
CONNECTION
The HTTPConnectionheader field name.- 另请参阅:
-
CONTENT_ENCODING
The HTTPContent-Encodingheader field name. -
CONTENT_DISPOSITION
The HTTPContent-Dispositionheader field name. -
CONTENT_LANGUAGE
The HTTPContent-Languageheader field name. -
CONTENT_LENGTH
The HTTPContent-Lengthheader field name. -
CONTENT_LOCATION
The HTTPContent-Locationheader field name. -
CONTENT_RANGE
The HTTPContent-Rangeheader field name.- 另请参阅:
-
CONTENT_TYPE
The HTTPContent-Typeheader field name. -
COOKIE
The HTTPCookieheader field name. -
DATE
The HTTPDateheader field name. -
ETAG
The HTTPETagheader field name.- 另请参阅:
-
EXPECT
The HTTPExpectheader field name. -
EXPIRES
The HTTPExpiresheader field name.- 另请参阅:
-
FROM
The HTTPFromheader field name. -
HOST
The HTTPHostheader field name.- 另请参阅:
-
IF_MATCH
The HTTPIf-Matchheader field name.- 另请参阅:
-
IF_MODIFIED_SINCE
The HTTPIf-Modified-Sinceheader field name.- 另请参阅:
-
IF_NONE_MATCH
The HTTPIf-None-Matchheader field name.- 另请参阅:
-
IF_RANGE
The HTTPIf-Rangeheader field name.- 另请参阅:
-
IF_UNMODIFIED_SINCE
The HTTPIf-Unmodified-Sinceheader field name.- 另请参阅:
-
LAST_MODIFIED
The HTTPLast-Modifiedheader field name.- 另请参阅:
-
LINK
The HTTPLinkheader field name. -
LOCATION
The HTTPLocationheader field name. -
MAX_FORWARDS
The HTTPMax-Forwardsheader field name. -
ORIGIN
The HTTPOriginheader field name. -
PRAGMA
The HTTPPragmaheader field name.- 另请参阅:
-
PROXY_AUTHENTICATE
The HTTPProxy-Authenticateheader field name.- 另请参阅:
-
PROXY_AUTHORIZATION
The HTTPProxy-Authorizationheader field name.- 另请参阅:
-
RANGE
The HTTPRangeheader field name.- 另请参阅:
-
REFERER
The HTTPRefererheader field name. -
RETRY_AFTER
The HTTPRetry-Afterheader field name. -
SERVER
The HTTPServerheader field name. -
SET_COOKIE
The HTTPSet-Cookieheader field name. -
SET_COOKIE2
The HTTPSet-Cookie2header field name. -
TE
The HTTPTEheader field name.- 另请参阅:
-
TRAILER
The HTTPTrailerheader field name.- 另请参阅:
-
TRANSFER_ENCODING
The HTTPTransfer-Encodingheader field name. -
UPGRADE
The HTTPUpgradeheader field name.- 另请参阅:
-
USER_AGENT
The HTTPUser-Agentheader field name. -
VARY
The HTTPVaryheader field name. -
VIA
The HTTPViaheader field name. -
WARNING
The HTTPWarningheader field name.- 另请参阅:
-
WWW_AUTHENTICATE
The HTTPWWW-Authenticateheader field name.- 另请参阅:
-
CONTENT_TRANSFER_ENCODING
- 另请参阅:
-
X_REQUESTED_WITH
- 另请参阅:
-
SEC_WEBSOCKET_ORIGIN
- 另请参阅:
-
SEC_WEBSOCKET_ACCEPT
- 另请参阅:
-
SEC_WEBSOCKET_VERSION
- 另请参阅:
-
SEC_WEBSOCKET_PROTOCOL
- 另请参阅:
-
SEC_WEBSOCKET_EXTENSIONS
- 另请参阅:
-
SEC_WEBSOCKET_LOCATION
- 另请参阅:
-
SEC_WEBSOCKET_KEY
- 另请参阅:
-
WEBSOCKET_LOCATION
- 另请参阅:
-
WEBSOCKET_PROTOCOL
- 另请参阅:
-
SEC_WEBSOCKET_KEY1
- 另请参阅:
-
SEC_WEBSOCKET_KEY2
- 另请参阅:
-
NONE
- 另请参阅:
-
GZIP
- 另请参阅:
-
BYTES
- 另请参阅:
-
CLOSE
- 另请参阅:
-
PUBLIC
- 另请参阅:
-
BASE64
- 另请参阅:
-
BINARY
- 另请参阅:
-
CHUNKED
- 另请参阅:
-
CHARSET
- 另请参阅:
-
MAX_AGE
- 另请参阅:
-
DEFLATE
- 另请参阅:
-
PRIVATE
- 另请参阅:
-
BOUNDARY
- 另请参阅:
-
IDENTITY
- 另请参阅:
-
NO_CACHE
- 另请参阅:
-
NO_STORE
- 另请参阅:
-
S_MAXAGE
- 另请参阅:
-
TRAILERS
- 另请参阅:
-
COMPRESS
- 另请参阅:
-
MAX_STALE
- 另请参阅:
-
MIN_FRESH
- 另请参阅:
-
WEBSOCKET
- 另请参阅:
-
KEEP_ALIVE
- 另请参阅:
-
GZIP_DEFLATE
- 另请参阅:
-
CONTINUE
- 另请参阅:
-
NO_TRANSFORM
- 另请参阅:
-
ONLY_IF_CACHED
- 另请参阅:
-
XML_HTTP_REQUEST
- 另请参阅:
-
MUST_REVALIDATE
- 另请参阅:
-
PROXY_REVALIDATE
- 另请参阅:
-
QUOTED_PRINTABLE
- 另请参阅:
-
MULTIPART_FORM_DATA
- 另请参阅:
-
INLINE_FILE_NAME
- 另请参阅:
-
ATTACHMENT_FILE_NAME
- 另请参阅:
-
APPLICATION_OCTET_STREAM
- 另请参阅:
-
APPLICATION_FORCE_DOWNLOAD
- 另请参阅:
-
APPLICATION_X_WWW_FORM_URLENCODED
- 另请参阅:
-
ETAG_HEADER_VALUE_PATTERN
Pattern matching ETag multiple field values in headers such as "If-Match", "If-None-Match".- 另请参阅:
-
DECIMAL_FORMAT_SYMBOLS
-
GMT
-
DATE_FORMATTER
Date formats with time zone as specified in the HTTP RFC to use for formatting. -
DATE_PARSERS
Date formats with time zone as specified in the HTTP RFC to use for parsing.
-
-
构造器详细资料
-
HttpHeaders
public HttpHeaders()
-
-
方法详细资料
-
getOrEmpty
Get the list of header values for the given header name, if any.- 参数:
headerName- the header name- 返回:
- the list of header values, or an empty list
-
setAccept
Set the list of acceptable media types, as specified by theAcceptheader. -
getAccept
Return the list of acceptable media types, as specified by theAcceptheader.Returns an empty list when the acceptable media types are unspecified.
-
setAcceptLanguage
Set the acceptable language ranges, as specified by the Accept-Language header. -
getAcceptLanguage
Return the language ranges from the "Accept-Language" header.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 toLocale.filter(List, Collection).- 抛出:
IllegalArgumentException- if the value cannot be converted to a language range
-
setAcceptLanguageAsLocales
Variant ofsetAcceptLanguage(Collection)usingLocale's. -
getAcceptLanguageAsLocales
- 返回:
- the locales or an empty list
- 抛出:
IllegalArgumentException- if the value cannot be converted to a locale
-
setAcceptPatch
- 从以下版本开始:
- 4.0
-
getAcceptPatch
Return the list of acceptable media types forPATCHmethods, as specified by theAccept-Patchheader.Returns an empty list when the acceptable media types are unspecified.
- 从以下版本开始:
- 4.0
-
setAccessControlAllowCredentials
public void setAccessControlAllowCredentials(boolean allowCredentials) Set the (new) value of theAccess-Control-Allow-Credentialsresponse header. -
getAccessControlAllowCredentials
public boolean getAccessControlAllowCredentials()Return the value of theAccess-Control-Allow-Credentialsresponse header. -
setAccessControlAllowHeaders
Set the (new) value of theAccess-Control-Allow-Headersresponse header. -
getAccessControlAllowHeaders
Return the value of theAccess-Control-Allow-Headersresponse header. -
setAccessControlAllowMethods
Set the (new) value of theAccess-Control-Allow-Methodsresponse header. -
getAccessControlAllowMethods
Return the value of theAccess-Control-Allow-Methodsresponse header. -
setAccessControlAllowOrigin
Set the (new) value of theAccess-Control-Allow-Originresponse header. -
getAccessControlAllowOrigin
Return the value of theAccess-Control-Allow-Originresponse header. -
setAccessControlExposeHeaders
Set the (new) value of theAccess-Control-Expose-Headersresponse header. -
getAccessControlExposeHeaders
Return the value of theAccess-Control-Expose-Headersresponse header. -
setAccessControlMaxAge
Set the (new) value of theAccess-Control-Max-Ageresponse header. -
setAccessControlMaxAge
public void setAccessControlMaxAge(long maxAge) Set the (new) value of theAccess-Control-Max-Ageresponse header. -
getAccessControlMaxAge
public long getAccessControlMaxAge()Return the value of theAccess-Control-Max-Ageresponse header.Returns -1 when the max age is unknown.
-
setAccessControlRequestHeaders
Set the (new) value of theAccess-Control-Request-Headersrequest header. -
getAccessControlRequestHeaders
Return the value of theAccess-Control-Request-Headersrequest header. -
setAccessControlRequestMethod
Set the (new) value of theAccess-Control-Request-Methodrequest header. -
getAccessControlRequestMethod
Return the value of theAccess-Control-Request-Methodrequest header. -
setAcceptCharset
Set the list of acceptable charsets, as specified by theAccept-Charsetheader. -
getAcceptCharset
Return the list of acceptable charsets, as specified by theAccept-Charsetheader. -
setAllow
Set the set of allowedHTTP methods, as specified by theAllowheader. -
setAllow
Set the set of allowedHTTP methods, as specified by theAllowheader. -
setAllow
Set the set of allowedHTTP methods, as specified by theAllowheader. -
getAllow
Return the set of allowedHTTP methods, as specified by theAllowheader.Returns an empty set when the allowed methods are unspecified.
-
setBasicAuth
Set the value of the Authorization header to Basic Authentication- 参数:
encodedCredentials- the encoded credentials- 抛出:
IllegalArgumentException- if supplied credentials string isnullor blank- 另请参阅:
-
setBasicAuth
Set the value of the Authorization header to Basic Authentication based on the given username and password.Note that this method only supports characters in the
ISO-8859-1character set.- 参数:
username- the usernamepassword- the password- 抛出:
IllegalArgumentException- if eitheruserorpasswordcontain characters that cannot be encoded to ISO-8859-1- 另请参阅:
-
setBasicAuth
Set the value of the Authorization header to Basic Authentication based on the given username and password.- 参数:
username- the usernamepassword- the passwordcharset- the charset to use to convert the credentials into an octet sequence. Defaults to ISO-8859-1.- 抛出:
IllegalArgumentException- ifusernameorpasswordcontains characters that cannot be encoded to the given charset- 另请参阅:
-
setBearerAuth
Set the value of the Authorization header to the given Bearer token.- 参数:
token- the Base64 encoded token- 另请参阅:
-
setCacheControl
Set a configuredCacheControlinstance as the new value of theCache-Controlheader. -
setCacheControl
Set the (new) value of theCache-Controlheader. -
getCacheControl
Return the value of theCache-Controlheader. -
setConnection
Set the (new) value of theConnectionheader. -
setConnection
Set the (new) value of theConnectionheader. -
getConnection
Return the value of theConnectionheader. -
setContentDispositionFormData
Set theContent-Dispositionheader 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 theRestTemplateorWebClient.- 参数:
name- the control namefilename- the filename (may benull)- 另请参阅:
-
setContentDisposition
Set the Content-Disposition header.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 onsetContentDispositionFormData(java.lang.String, java.lang.String).- 另请参阅:
-
setContentDisposition
-
getContentDisposition
Return a parsed representation of the Content-Disposition header. -
setContentLanguage
Set theLocaleof the content language, as specified by the Content-Language header.Use
put(CONTENT_LANGUAGE, list)if you need to set multiple content languages. -
getContentLanguage
Return the firstLocaleof the content languages, as specified by the Content-Language header.Returns
nullwhen the content language is unknown.Use
getValuesAsList(CONTENT_LANGUAGE)if you need to get multiple content languages. -
setContentLength
public void setContentLength(long contentLength) Set the length of the body in bytes, as specified by theContent-Lengthheader. -
getContentLength
public long getContentLength()Return the length of the body in bytes, as specified by theContent-Lengthheader.Returns -1 when the content-length is unknown.
-
setContentType
Set the media type of the body, as specified by theContent-Typeheader. -
getContentType
Return the media type of the body, as specified by theContent-Typeheader.Returns
nullwhen theContent-Typeheader is not set.- 抛出:
InvalidMediaTypeException- if the media type value cannot be parsed
-
setDate
Set the date and time at which the message was created, as specified by theDateheader. -
setDate
Set the date and time at which the message was created, as specified by theDateheader. -
setDate
public void setDate(long date) Set the date and time at which the message was created, as specified by theDateheader.The date should be specified as the number of milliseconds since January 1, 1970 GMT.
-
getDate
public long getDate()Return the date and time at which the message was created, as specified by theDateheader.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 date
-
setETag
Set the (new) entity tag of the body, as specified by theETagheader. -
getETag
Return the entity tag of the body, as specified by theETagheader. -
setExpires
Set the duration after which the message is no longer valid, as specified by theExpiresheader. -
setExpires
Set the date and time at which the message is no longer valid, as specified by theExpiresheader. -
setExpires
public void setExpires(long expires) Set the date and time at which the message is no longer valid, as specified by theExpiresheader.The date should be specified as the number of milliseconds since January 1, 1970 GMT.
-
getExpires
public long getExpires()Return the date and time at which the message is no longer valid, as specified by theExpiresheader.The date is returned as the number of milliseconds since January 1, 1970 GMT. Returns -1 when the date is unknown.
-
setHost
-
getHost
Return the value of theHostheader, if available.If the header value does not contain a port, the port in the returned address will be
0. -
setIfMatch
Set the (new) value of theIf-Matchheader. -
setIfMatch
Set the (new) value of theIf-Matchheader. -
getIfMatch
Return the value of theIf-Matchheader. -
setIfModifiedSince
Set the time the resource was last changed, as specified by theLast-Modifiedheader. -
setIfModifiedSince
Set the time the resource was last changed, as specified by theLast-Modifiedheader. -
setIfModifiedSince
public void setIfModifiedSince(long ifModifiedSince) Set the (new) value of theIf-Modified-Sinceheader.The date should be specified as the number of milliseconds since January 1, 1970 GMT.
-
getIfModifiedSince
public long getIfModifiedSince()Return the value of theIf-Modified-Sinceheader.The date is returned as the number of milliseconds since January 1, 1970 GMT. Returns -1 when the date is unknown.
-
setIfNoneMatch
Set the (new) value of theIf-None-Matchheader. -
setIfNoneMatch
Set the (new) values of theIf-None-Matchheader. -
getIfNoneMatch
Return the value of theIf-None-Matchheader. -
setIfUnmodifiedSince
Set the time the resource was last changed, as specified by theLast-Modifiedheader. -
setIfUnmodifiedSince
Set the time the resource was last changed, as specified by theLast-Modifiedheader. -
setIfUnmodifiedSince
public void setIfUnmodifiedSince(long ifUnmodifiedSince) Set the (new) value of theIf-Unmodified-Sinceheader.The date should be specified as the number of milliseconds since January 1, 1970 GMT.
-
getIfUnmodifiedSince
public long getIfUnmodifiedSince()Return the value of theIf-Unmodified-Sinceheader.The date is returned as the number of milliseconds since January 1, 1970 GMT. Returns -1 when the date is unknown.
-
setLastModified
Set the time the resource was last changed, as specified by theLast-Modifiedheader. -
setLastModified
Set the time the resource was last changed, as specified by theLast-Modifiedheader. -
setLastModified
public void setLastModified(long lastModified) Set the time the resource was last changed, as specified by theLast-Modifiedheader.The date should be specified as the number of milliseconds since January 1, 1970 GMT.
-
getLastModified
public long getLastModified()Return the time the resource was last changed, as specified by theLast-Modifiedheader.The date is returned as the number of milliseconds since January 1, 1970 GMT. Returns -1 when the date is unknown.
-
setLocation
Set the (new) location of a resource, as specified by theLocationheader. -
setLocation
Set the (new) location of a resource, as specified by theLocationheader.- 从以下版本开始:
- 4.0
-
getLocation
Return the (new) location of a resource as specified by theLocationheader.Returns
nullwhen the location is unknown. -
setOrigin
Set the (new) value of theOriginheader. -
getOrigin
Return the value of theOriginheader. -
setPragma
Set the (new) value of thePragmaheader. -
getPragma
Return the value of thePragmaheader. -
setRange
Sets the (new) value of theRangeheader. -
getRange
Return the value of theRangeheader.Returns an empty list when the range is unknown.
-
setUpgrade
Set the (new) value of theUpgradeheader. -
getUpgrade
Return the value of theUpgradeheader. -
setVary
Set the request header names (e.g. "Accept-Language") for which the response is subject to content negotiation and variances based on the value of those request headers.- 参数:
requestHeaders- the request header names
-
setVary
Set the request header names (e.g. "Accept-Language") for which the response is subject to content negotiation and variances based on the value of those request headers.- 参数:
requestHeaders- the request header names
-
getVary
Return the request header names subject to content negotiation. -
setZonedDateTime
Set the given date under the given header name after formatting it as a string using the RFC-1123 date-time formatter. The equivalent ofset(String, String)but for date headers. -
setInstant
Set the given date under the given header name after formatting it as a string using the RFC-1123 date-time formatter. The equivalent ofset(String, String)but for date headers. -
setDate
Set the given date under the given header name after formatting it as a string using the RFC-1123 date-time formatter. The equivalent ofset(String, String)but for date headers. -
getFirstDate
Parse the first header value for the given header name as a date, return -1 if there is no value, or raiseIllegalArgumentExceptionif the value cannot be parsed as a date.- 参数:
headerName- the header name- 返回:
- the parsed date header, or -1 if none
- 另请参阅:
-
getFirstDate
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 (ifrejectInvalid=false), or raiseIllegalArgumentExceptionif the value cannot be parsed as a date.- 参数:
headerName- the header namerejectInvalid- whether to reject invalid values with anIllegalArgumentException(true) or rather return -1 in that case (false)- 返回:
- the parsed date header, or -1 if none (or invalid)
- 另请参阅:
-
getFirstZonedDateTime
Parse the first header value for the given header name as a date, returnnullif there is no value, or raiseIllegalArgumentExceptionif the value cannot be parsed as a date.- 参数:
headerName- the header name- 返回:
- the parsed date header, or
nullif none
-
getFirstZonedDateTime
Parse the first header value for the given header name as a date, returnnullif there is no value or also in case of an invalid value (ifrejectInvalid=false), or raiseIllegalArgumentExceptionif the value cannot be parsed as a date.- 参数:
headerName- the header namerejectInvalid- whether to reject invalid values with anIllegalArgumentException(true) or rather returnnullin that case (false)- 返回:
- the parsed date header, or
nullif none (or invalid)
-
getValuesAsList
Return all values of a given header name, even if this header is set multiple times.- 参数:
headerName- the header name- 返回:
- all associated values
-
tokenizeQuoted
-
addToken
-
clearContentHeaders
public void clearContentHeaders()Remove the well-known"Content-*"HTTP headers.Such headers should be cleared from the response if the intended body can't be written due to errors.
-
getETagValuesAsList
Retrieve a combined result from the field values of the ETag header.- 参数:
headerName- the header name- 返回:
- the combined result
-
getFieldValues
Retrieve a combined result from the field values of multi-valued headers.- 参数:
headerName- the header name- 返回:
- the combined result
-
toCommaDelimitedString
Turn the given list of header values into a comma-delimited result.- 参数:
headerValues- the list of header values- 返回:
- a combined result with comma delimitation
-
setOrRemove
Set the given header value, or remove the header ifnull.- 参数:
headerName- the header nameheaderValue- the header value, ornullfor none
-
getFirst
Return the first header value for the given header name, if any. -
add
Add the given, single header value under the given name.- 指定者:
add在接口中cn.taketoday.util.MultiValueMap<String,String> - 参数:
headerName- the header nameheaderValue- the header value- 抛出:
UnsupportedOperationException- if adding headers is not supported- 另请参阅:
-
set
-
get
-
remove
-
toString
-
formatHeaders
Helps to format HTTP header values, as HTTP header values themselves can contain comma-separated values, can become confusing with regularMapformatting that also uses commas between entries.- 参数:
headers- the headers to format- 返回:
- the headers to a String
-
encodeBasicAuth
Encode the given username and password into Basic Authentication credentials.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- ifusernameorpasswordcontains characters that cannot be encoded to the given charset- 另请参阅:
-
empty
- 返回:
- returns empty http-headers
- 从以下版本开始:
- 4.0
-
create
- 返回:
- returns a new DefaultHttpHeaders
- 从以下版本开始:
- 4.0
-
from
Construct a newHttpHeadersinstance 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 original map- 返回:
- the adapted multi-value map (wrapping the original map)
- 从以下版本开始:
- 4.0
-
readOnlyHttpHeaders
public static HttpHeaders readOnlyHttpHeaders(cn.taketoday.util.MultiValueMap<String, String> headers) Apply a read-onlyHttpHeaderswrapper around the given headers, if necessary.Also caches the parsed representations of the "Accept" and "Content-Type" headers.
- 参数:
headers- the headers to expose- 返回:
- a read-only variant of the headers, or the original headers as-is
(in case it happens to be a read-only
HttpHeadersinstance already) - 从以下版本开始:
- 4.0
-
readOnlyHttpHeaders
Apply a read-onlyHttpHeaderswrapper around the given headers, if necessary.Also caches the parsed representations of the "Accept" and "Content-Type" headers.
- 参数:
headers- the headers to expose- 返回:
- a read-only variant of the headers, or the original headers as-is
- 从以下版本开始:
- 4.0
-
writableHttpHeaders
Remove any read-only wrapper that may have been previously applied around the given headers viareadOnlyHttpHeaders(HttpHeaders).- 参数:
headers- the headers to expose- 返回:
- a writable variant of the headers, or the original headers as-is
- 从以下版本开始:
- 4.0
-
copyOf
copy targetMap’s all entries to a new HttpHeaders- 参数:
targetMap- can be null- 返回:
- returns
empty()iftargetMapis null - 从以下版本开始:
- 4.0
-
formatDate
-