接口 ServerResponse.HeadersBuilder<B extends ServerResponse.HeadersBuilder<B>>
- 类型参数:
B
- the builder subclass
- 所有已知子接口:
ServerResponse.BodyBuilder
- 封闭接口:
- ServerResponse
public static interface ServerResponse.HeadersBuilder<B extends ServerResponse.HeadersBuilder<B>>
Defines a builder that adds headers to the response.
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 B
allow(Set<HttpMethod> allowedMethods)
Set the set of allowedHTTP methods
, as specified by theAllow
header.B
allow(HttpMethod... allowedMethods)
Set the set of allowedHTTP methods
, as specified by theAllow
header.reactor.core.publisher.Mono<ServerResponse>
build()
Build the response entity with no body.reactor.core.publisher.Mono<ServerResponse>
build(BiFunction<ServerWebExchange,ServerResponse.Context,reactor.core.publisher.Mono<Void>> writeFunction)
Build the response entity with a custom writer function.reactor.core.publisher.Mono<ServerResponse>
build(org.reactivestreams.Publisher<Void> voidPublisher)
Build the response entity with no body.B
cacheControl(CacheControl cacheControl)
Set the caching directives for the resource, as specified by the HTTP 1.1Cache-Control
header.B
cookie(ResponseCookie cookie)
Add the given cookie to the response.B
cookies(Consumer<MultiValueMap<String,ResponseCookie>> cookiesConsumer)
Manipulate this response's cookies with the given consumer.B
eTag(String eTag)
Set the entity tag of the body, as specified by theETag
header.B
header(String headerName, String... headerValues)
Add the given header value(s) under the given name.B
headers(Consumer<HttpHeaders> headersConsumer)
Manipulate this response's headers with the given consumer.B
lastModified(Instant lastModified)
Set the time the resource was last changed, as specified by theLast-Modified
header.B
lastModified(ZonedDateTime lastModified)
Set the time the resource was last changed, as specified by theLast-Modified
header.B
location(URI location)
Set the location of a resource, as specified by theLocation
header.B
varyBy(String... requestHeaders)
Configure one or more request header names (e.g.
方法详细资料
header
B header(String headerName, String... headerValues)
Add the given header value(s) under the given name.- 参数:
headerName
- the header nameheaderValues
- the header value(s)- 返回:
- this builder
- 另请参阅:
HttpHeaders.add(String, String)
headers
B headers(Consumer<HttpHeaders> headersConsumer)
Manipulate this response's headers with the given consumer. The headers provided to the consumer are "live", so that the consumer can be used to overwrite existing header values, remove values, or use any of the otherHttpHeaders
methods.- 参数:
headersConsumer
- a function that consumes theHttpHeaders
- 返回:
- this builder
cookie
B cookie(ResponseCookie cookie)
Add the given cookie to the response.- 参数:
cookie
- the cookie to add- 返回:
- this builder
cookies
B cookies(Consumer<MultiValueMap<String,ResponseCookie>> cookiesConsumer)
Manipulate this response's cookies with the given consumer. The cookies provided to the consumer are "live", so that the consumer can be used to overwrite existing cookies, remove cookies, or use any of the otherMultiValueMap
methods.- 参数:
cookiesConsumer
- a function that consumes the cookies- 返回:
- this builder
allow
B allow(HttpMethod... allowedMethods)
Set the set of allowedHTTP methods
, as specified by theAllow
header.- 参数:
allowedMethods
- the allowed methods- 返回:
- this builder
- 另请参阅:
HttpHeaders.setAllow(Set)
allow
B allow(Set<HttpMethod> allowedMethods)
Set the set of allowedHTTP methods
, as specified by theAllow
header.- 参数:
allowedMethods
- the allowed methods- 返回:
- this builder
- 另请参阅:
HttpHeaders.setAllow(Set)
eTag
B eTag(String eTag)
Set the entity tag of the body, as specified by theETag
header.- 参数:
eTag
- the new entity tag- 返回:
- this builder
- 另请参阅:
HttpHeaders.setETag(String)
lastModified
B lastModified(ZonedDateTime lastModified)
Set the time the resource was last changed, as specified by theLast-Modified
header.- 参数:
lastModified
- the last modified date- 返回:
- this builder
- 另请参阅:
HttpHeaders.setLastModified(long)
lastModified
B lastModified(Instant lastModified)
Set the time the resource was last changed, as specified by theLast-Modified
header.- 参数:
lastModified
- the last modified date- 返回:
- this builder
- 从以下版本开始:
- 5.1.4
- 另请参阅:
HttpHeaders.setLastModified(long)
location
B location(URI location)
Set the location of a resource, as specified by theLocation
header.- 参数:
location
- the location- 返回:
- this builder
- 另请参阅:
HttpHeaders.setLocation(URI)
cacheControl
B cacheControl(CacheControl cacheControl)
Set the caching directives for the resource, as specified by the HTTP 1.1Cache-Control
header.A
CacheControl
instance can be built likeCacheControl.maxAge(3600).cachePublic().noTransform()
.- 参数:
cacheControl
- a builder for cache-related HTTP response headers- 返回:
- this builder
- 另请参阅:
- RFC-7234 Section 5.2
varyBy
B varyBy(String... requestHeaders)
Configure one or more request header names (e.g. "Accept-Language") to add to the "Vary" response header to inform clients that the response is subject to content negotiation and variances based on the value of the given request headers. The configured request header names are added only if not already present in the response "Vary" header.- 参数:
requestHeaders
- request header names- 返回:
- this builder
build
reactor.core.publisher.Mono<ServerResponse> build()
Build the response entity with no body.
build
reactor.core.publisher.Mono<ServerResponse> build(org.reactivestreams.Publisher<Void> voidPublisher)
Build the response entity with no body.The response will be committed when the given
voidPublisher
completes.- 参数:
voidPublisher
- the publisher to indicate when the response should be committed
build
reactor.core.publisher.Mono<ServerResponse> build(BiFunction<ServerWebExchange,ServerResponse.Context,reactor.core.publisher.Mono<Void>> writeFunction)
Build the response entity with a custom writer function.- 参数:
writeFunction
- the function used to write to theServerWebExchange