Interface ClientResponse.Builder
- Enclosing interface:
- ClientResponse
public static interface ClientResponse.Builder
Defines a builder for a response.
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ClientResponse.Builder
body(String body)
Set the body of the response to the UTF-8 encoded bytes of the given string.ClientResponse.Builder
body(reactor.core.publisher.Flux<DataBuffer> body)
Set the body of the response.ClientResponse
build()
Build the response.ClientResponse.Builder
cookie(String name, String... values)
Add a cookie with the given name and value(s).ClientResponse.Builder
cookies(Consumer<MultiValueMap<String,ResponseCookie>> cookiesConsumer)
Manipulate this response's cookies with the given consumer.ClientResponse.Builder
header(String headerName, String... headerValues)
Add the given header value(s) under the given name.ClientResponse.Builder
headers(Consumer<HttpHeaders> headersConsumer)
Manipulate this response's headers with the given consumer.ClientResponse.Builder
rawStatusCode(int statusCode)
Set the raw status code of the response.ClientResponse.Builder
request(HttpRequest request)
Set the request associated with the response.ClientResponse.Builder
statusCode(HttpStatus statusCode)
Set the status code of the response.
Method Detail
statusCode
ClientResponse.Builder statusCode(HttpStatus statusCode)
Set the status code of the response.- Parameters:
statusCode
- the new status code- Returns:
- this builder
rawStatusCode
ClientResponse.Builder rawStatusCode(int statusCode)
Set the raw status code of the response.- Parameters:
statusCode
- the new status code- Returns:
- this builder
- Since:
- 5.1.9
header
ClientResponse.Builder header(String headerName, String... headerValues)
Add the given header value(s) under the given name.- Parameters:
headerName
- the header nameheaderValues
- the header value(s)- Returns:
- this builder
- See Also:
HttpHeaders.add(String, String)
headers
ClientResponse.Builder 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 other
HttpHeaders
methods.- Parameters:
headersConsumer
- a function that consumes theHttpHeaders
- Returns:
- this builder
cookie
ClientResponse.Builder cookie(String name, String... values)
Add a cookie with the given name and value(s).- Parameters:
name
- the cookie namevalues
- the cookie value(s)- Returns:
- this builder
cookies
ClientResponse.Builder cookies(Consumer<MultiValueMap<String,ResponseCookie>> cookiesConsumer)
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(reactor.core.publisher.Flux<DataBuffer> body)
Set the body of the response.Calling this methods will release the existing body of the builder.
- Parameters:
body
- the new body- Returns:
- this builder
body
ClientResponse.Builder body(String body)
Set the body of the response to the UTF-8 encoded bytes of the given string.Calling this methods will release the existing body of the builder.
- Parameters:
body
- the new body- Returns:
- this builder
request
ClientResponse.Builder request(HttpRequest request)
Set the request associated with the response.- Parameters:
request
- the request- Returns:
- this builder
- Since:
- 5.2
build
ClientResponse build()
Build the response.