Interface ClientResponse.Builder

Enclosing interface:
ClientResponse

public static interface ClientResponse.Builder
Defines a builder for a response.
  • Method Details

    • statusCode

      ClientResponse.Builder statusCode(HttpStatusCode 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 name
      headerValues - the header value(s)
      Returns:
      this builder
      See Also:
    • 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 the HttpHeaders
      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 name
      values - 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

      ClientResponse.Builder body(reactor.core.publisher.Flux<DataBuffer> 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

      Build the response.