Interface ClientResponse.Builder
- Enclosing interface:
- ClientResponse
public static interface ClientResponse.Builder
Defines a builder for a response.
- Since:
- 5.0
- Author:
- Brian Clozel, Arjen Poutsma
- 
Method SummaryModifier 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(HttpStatusCode statusCode) Set the status code of the response.
- 
Method Details- 
statusCodeSet the status code of the response.- Parameters:
- statusCode- the new status code
- Returns:
- this builder
 
- 
rawStatusCodeSet the raw status code of the response.- Parameters:
- statusCode- the new status code
- Returns:
- this builder
- Since:
- 5.1.9
 
- 
headerAdd the given header value(s) under the given name.- Parameters:
- headerName- the header name
- headerValues- the header value(s)
- Returns:
- this builder
- See Also:
 
- 
headersManipulate 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 HttpHeadersmethods.- Parameters:
- headersConsumer- a function that consumes the- HttpHeaders
- Returns:
- this builder
 
- 
cookieAdd a cookie with the given name and value(s).- Parameters:
- name- the cookie name
- values- the cookie value(s)
- Returns:
- this builder
 
- 
cookiesManipulate 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 MultiValueMapmethods.- Parameters:
- cookiesConsumer- a function that consumes the cookies map
- Returns:
- this builder
 
- 
bodyClientResponse.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
 
- 
bodySet 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
 
- 
bodySet 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
 
- 
requestSet the request associated with the response.- Parameters:
- request- the request
- Returns:
- this builder
- Since:
- 5.2
 
- 
buildClientResponse build()Build the response.
 
-