Interface ServerResponseHeaders
- All Superinterfaces:
ClientResponseHeaders, Headers, Iterable<Header>, WritableHeaders<ServerResponseHeaders>
public interface ServerResponseHeaders
extends ClientResponseHeaders, WritableHeaders<ServerResponseHeaders>
Mutable headers of a server response.
-
Method Summary
Modifier and TypeMethodDescriptiondefault ServerResponseHeadersaddAcceptPatches(MediaType... acceptableMediaTypes) Adds one or more acceptedTypes path document formats (headerHeaderNames.ACCEPT_PATCH).default ServerResponseHeadersaddAcceptQueries(MediaType... acceptableMediaTypes) Adds one or more media types supported by this resource forMethod.QUERYrequest content (headerHeaderNames.ACCEPT_QUERY).AddsSet-Cookieheader specified in RFC6265.default ServerResponseHeadersAddsSet-Cookieheader based on RFC2616.default ServerResponseHeadersdefault ServerResponseHeadersclearCookie(SetCookie setCookie) Clears a cookie by adding aSet-Cookieheader with an expiration date in the past.clearCookie(String name) Clears a cookie by adding aSet-Cookieheader with an expiration date in the past.static ServerResponseHeaderscreate()Create a new instance of mutable server response headers.static ServerResponseHeadersCreate a new instance of mutable server response headers.default ServerResponseHeadersSets the value ofHeaderNames.EXPIRESheader.default ServerResponseHeadersexpires(ZonedDateTime dateTime) Sets the value ofHeaderNames.EXPIRESheader.default ServerResponseHeaderslastModified(Instant modified) Sets the value ofHeaderNames.LAST_MODIFIEDheader.default ServerResponseHeaderslastModified(ZonedDateTime modified) Sets the value ofHeaderNames.LAST_MODIFIEDheader.default ServerResponseHeadersSets the value ofHeaderNames.LOCATIONheader.Methods inherited from interface ClientResponseHeaders
acceptPatches, acceptQueries, expires, lastModified, locationModifier and TypeMethodDescriptiondefault List<HttpMediaType> Accepted patches.default List<HttpMediaType> Media types supported by the resource forMethod.QUERYrequest content.default Optional<ZonedDateTime> expires()Optionally gets the value ofHeaderNames.EXPIRESheader.default Optional<ZonedDateTime> Optionally gets the value ofHeaderNames.LAST_MODIFIEDheader.location()Optionally gets the value ofHeaderNames.LOCATIONheader.Methods inherited from interface Headers
acceptedTypes, all, contains, contains, containsToken, contentLength, contentType, find, first, get, isAccepted, size, stream, toMap, value, valuesModifier and TypeMethodDescriptionReturns a list of acceptedTypes (HeaderNames.ACCEPTheader) content discoveryTypes in quality factor order.all(HeaderName name, Supplier<List<String>> defaultSupplier) Get all values of a header.booleanWhether these headers contain a header with the provided name and value.booleancontains(HeaderName name) Whether these headers contain a header with the provided name.default booleancontainsToken(Header value) Whether these headers contain all tokenized values from the provided header.default OptionalLongContent length if defined.default Optional<HttpMediaType> Content type (if defined).find(HeaderName headerName) Find the first header.first(HeaderName headerName) Returns a first header value.get(HeaderName name) Get a header value.default booleanisAccepted(MediaType... mediaTypes) Whether this media type is accepted by these headers.intsize()Number of headers in these headers.stream()A sequential stream with these headers as the source.toMap()Deprecated.use other methods to handle headers, preferably using pull approachvalue(HeaderName headerName) Returns a header value as a singleStringpotentially concatenated using comma character fromHeaders.all(HeaderName, java.util.function.Supplier)header fields.values(HeaderName headerName) Returns an unmodifiableListof all comma separated header value parts - Such segmentation is NOT valid for all header semantics, however it is very common.Methods inherited from interface Iterable
forEach, iterator, spliteratorMethods inherited from interface WritableHeaders
add, add, add, add, clear, contentLength, contentType, from, remove, remove, set, set, set, set, set, setIfAbsentModifier and TypeMethodDescriptionAdd a header or add a header value if the header is already present.default ServerResponseHeadersadd(HeaderName header, int value) Add a header or add a header value if the header is already present.default ServerResponseHeadersadd(HeaderName header, long value) Add a header or add a header value if the header is already present.default ServerResponseHeadersadd(HeaderName header, String... value) Add a header or add a header value if the header is already present.clear()Clear all current headers.default ServerResponseHeaderscontentLength(long length) Content length of the entity in bytes.default ServerResponseHeaderscontentType(MediaType contentType) Sets the MIME type of the response body.For each header from the provided headers, set its value on these headers.remove(HeaderName name) Remove a header.remove(HeaderName name, Consumer<Header> removedConsumer) Remove a header.Set a header and replace it if it already existed.default ServerResponseHeadersset(HeaderName name, int value) Set a header and replace it if it already existed.default ServerResponseHeadersset(HeaderName name, long value) Set a header and replace it if it already existed.default ServerResponseHeadersset(HeaderName name, String... values) Set a header and replace it if it already existed.default ServerResponseHeadersset(HeaderName name, Collection<String> values) Set a header and replace it if it already existed.setIfAbsent(Header header) Set a value of a header unless it is already present.
-
Method Details
-
create
Create a new instance of mutable server response headers.- Returns:
- new server response headers
-
create
Create a new instance of mutable server response headers.- Parameters:
existing- headers to add to these response headers- Returns:
- new server response headers
-
addAcceptPatches
Adds one or more acceptedTypes path document formats (headerHeaderNames.ACCEPT_PATCH).- Parameters:
acceptableMediaTypes- media types to add.- Returns:
- this instance
-
addAcceptQueries
Adds one or more media types supported by this resource forMethod.QUERYrequest content (headerHeaderNames.ACCEPT_QUERY).HttpMediaTypemay be used to add media type parameters.- Parameters:
acceptableMediaTypes- media types to add- Returns:
- this instance
-
addCookie
AddsSet-Cookieheader specified in RFC6265.- Parameters:
cookie- a cookie definition- Returns:
- this instance
-
addCookie
- Parameters:
name- name of the cookievalue- value of the cookiemaxAge-Max-Agecookie parameter- Returns:
- this instance
-
addCookie
AddsSet-Cookieheader based on RFC2616.- Parameters:
name- name of the cookievalue- value of the cookie- Returns:
- this instance
-
clearCookie
Clears a cookie by adding aSet-Cookieheader with an expiration date in the past. It is recommended to useclearCookie(SetCookie)instead for better handling of Path and Domain.- Parameters:
name- name of the cookie.- Returns:
- this instance
-
clearCookie
Clears a cookie by adding aSet-Cookieheader with an expiration date in the past.- Parameters:
setCookie- the cookie.- Returns:
- this instance
-
lastModified
Sets the value ofHeaderNames.LAST_MODIFIEDheader.The last modified date for the requested object
- Parameters:
modified- Last modified date/time.- Returns:
- this instance
-
lastModified
Sets the value ofHeaderNames.LAST_MODIFIEDheader.The last modified date for the requested object
- Parameters:
modified- Last modified date/time.- Returns:
- this instance
-
location
Sets the value ofHeaderNames.LOCATIONheader.Used in redirection, or when a new resource has been created.
- Parameters:
location- Location header value.- Returns:
- updated headers
-
expires
Sets the value ofHeaderNames.EXPIRESheader.The date/time after which the response is considered stale.
- Parameters:
dateTime- Expires date/time.- Returns:
- updated headers
-
expires
Sets the value ofHeaderNames.EXPIRESheader.The date/time after which the response is considered stale.
- Parameters:
dateTime- Expires date/time.- Returns:
- updated headers
-