Interface ClientResponse.Builder
- Enclosing interface:
- ClientResponse
public static interface ClientResponse.Builder
Defines a builder for a response.
-
Method Summary
Modifier and TypeMethodDescriptionSet the body of the response to the UTF-8 encoded bytes of the given string.body
(Function<reactor.core.publisher.Flux<DataBuffer>, reactor.core.publisher.Flux<DataBuffer>> transformer) Transform the response body, if set in the builder.body
(reactor.core.publisher.Flux<DataBuffer> body) Set the body of the response.build()
Build the response.Add a cookie with the given name and value(s).cookies
(Consumer<MultiValueMap<String, ResponseCookie>> cookiesConsumer) Manipulate this response's cookies with the given consumer.Add the given header value(s) under the given name.headers
(Consumer<HttpHeaders> headersConsumer) Manipulate this response's headers with the given consumer.rawStatusCode
(int statusCode) Set the raw status code of the response.request
(HttpRequest request) Set the request associated with the response.statusCode
(HttpStatus statusCode) Set the status code of the response.
-
Method Details
-
statusCode
Set the status code of the response.- Parameters:
statusCode
- the new status code- Returns:
- this builder
-
rawStatusCode
Set the raw status code of the response.- Parameters:
statusCode
- the new status code- Returns:
- this builder
- Since:
- 5.1.9
-
header
Add the given header value(s) under the given name.- Parameters:
headerName
- the header nameheaderValues
- the header value(s)- Returns:
- this builder
- See Also:
-
headers
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 other
HttpHeaders
methods.- Parameters:
headersConsumer
- a function that consumes theHttpHeaders
- Returns:
- this builder
-
cookie
Add a cookie with the given name and value(s).- Parameters:
name
- the cookie namevalues
- the cookie value(s)- Returns:
- this builder
-
cookies
Manipulate this response's cookies with the given consumer.The map provided to the consumer is "live", so that the consumer can be used to overwrite existing cookie values, remove values, or use any of the other
MultiValueMap
methods.- Parameters:
cookiesConsumer
- a function that consumes the cookies map- Returns:
- this builder
-
body
ClientResponse.Builder body(Function<reactor.core.publisher.Flux<DataBuffer>, reactor.core.publisher.Flux<DataBuffer>> transformer) Transform the response body, if set in the builder.- Parameters:
transformer
- the transformation function to use- Returns:
- this builder
- Since:
- 5.3
-
body
Set the body of the response.Note: This method will drain the existing body, if set in the builder.
- Parameters:
body
- the new body to use- Returns:
- this builder
-
body
Set the body of the response to the UTF-8 encoded bytes of the given string.Note: This method will drain the existing body, if set in the builder.
- Parameters:
body
- the new body.- Returns:
- this builder
-
request
Set the request associated with the response.- Parameters:
request
- the request- Returns:
- this builder
- Since:
- 5.2
-
build
ClientResponse build()Build the response.
-