org.springframework.web.reactive.function.client

## Interface WebClient.ResponseSpec

Enclosing interface:
  WebClient

    public static interface WebClient.ResponseSpec

Contract for specifying response operations following the exchange.

### Method Summary

All Methods Instance Methods Abstract Methods
`<T> reactor.core.publisher.Flux<T>` `bodyToFlux(Class<T> elementClass)` Extract the body to a `Flux`.
`<T> reactor.core.publisher.Flux<T>` `bodyToFlux(org.springframework.core.ParameterizedTypeReference<T> elementTypeRef)` Extract the body to a `Flux`.
`<T> reactor.core.publisher.Mono<T>` `bodyToMono(Class<T> elementClass)` Extract the body to a `Mono`.
`<T> reactor.core.publisher.Mono<T>` `bodyToMono(org.springframework.core.ParameterizedTypeReference<T> elementTypeRef)` Extract the body to a `Mono`.
`WebClient.ResponseSpec` `onRawStatus(IntPredicate statusCodePredicate, Function<ClientResponse,reactor.core.publisher.Mono<? extends Throwable>> exceptionFunction)` Variant of `onStatus(Predicate, Function)` that works with raw status code values.
`WebClient.ResponseSpec` `onStatus(Predicate<org.springframework.http.HttpStatus> statusPredicate, Function<ClientResponse,reactor.core.publisher.Mono<? extends Throwable>> exceptionFunction)` Provide a function to map specific error status codes to an error signal to be propagated downstream instead of the response.
`reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<Void>>` `toBodilessEntity()` Return the response as a delayed `ResponseEntity` containing status and headers, but no body.
`<T> reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<T>>` `toEntity(Class<T> bodyClass)` Return the response as a delayed `ResponseEntity`.
`<T> reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<T>>` `toEntity(org.springframework.core.ParameterizedTypeReference<T> bodyTypeReference)` Return the response as a delayed `ResponseEntity`.
`<T> reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<List<T>>>` `toEntityList(Class<T> elementClass)` Return the response as a delayed list of `ResponseEntity`s.
`<T> reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<List<T>>>` `toEntityList(org.springframework.core.ParameterizedTypeReference<T> elementTypeRef)` Return the response as a delayed list of `ResponseEntity`s.

### Method Detail

#### onStatus

    WebClient.ResponseSpec onStatus(Predicate<org.springframework.http.HttpStatus> statusPredicate,
                                    Function<ClientResponse,reactor.core.publisher.Mono<? extends Throwable>> exceptionFunction)

Provide a function to map specific error status codes to an error signal to be propagated downstream instead of the response.

By default, if there are no matching status handlers, responses with status codes >= 400 are mapped to `WebClientResponseException` which is created with `ClientResponse.createException()`.

To suppress the treatment of a status code as an error and process it as a normal response, return `Mono.empty()` from the function. The response will then propagate downstream to be processed.

To ignore an error response completely, and propagate neither response nor error, use a `filter`, or add `onErrorResume` downstream, for example:

     webClient.get()
         .uri("https://abc.com/account/123")
         .retrieve()
         .bodyToMono(Account.class)
         .onErrorResume(WebClientResponseException.class,
              ex -> ex.getRawStatusCode() == 404 ? Mono.empty() : Mono.error(ex));

Parameters:
  `statusPredicate` - to match responses with
  `exceptionFunction` - to map the response to an error signal
Returns:
  this builder
See Also:
  `ClientResponse.createException()`

#### onRawStatus

    WebClient.ResponseSpec onRawStatus(IntPredicate statusCodePredicate,
                                       Function<ClientResponse,reactor.core.publisher.Mono<? extends Throwable>> exceptionFunction)

Variant of `onStatus(Predicate, Function)` that works with raw status code values. This is useful for custom status codes.

Parameters:
  `statusCodePredicate` - to match responses with
  `exceptionFunction` - to map the response to an error signal
Returns:
  this builder
Since:
  5.1.9

#### bodyToMono

    <T> reactor.core.publisher.Mono<T> bodyToMono(Class<T> elementClass)

Extract the body to a `Mono`. By default, if the response has status code 4xx or 5xx, the `Mono` will contain a `WebClientException`. This can be overridden with `onStatus(Predicate, Function)`.

Type Parameters:
  `T` - response body type
Parameters:
  `elementClass` - the expected response body element class
Returns:
  a mono containing the body, or a `WebClientResponseException` if the status code is 4xx or 5xx

#### bodyToMono

    <T> reactor.core.publisher.Mono<T> bodyToMono(org.springframework.core.ParameterizedTypeReference<T> elementTypeRef)

Extract the body to a `Mono`. By default, if the response has status code 4xx or 5xx, the `Mono` will contain a `WebClientException`. This can be overridden with `onStatus(Predicate, Function)`.

Type Parameters:
  `T` - response body type
Parameters:
  `elementTypeRef` - a type reference describing the expected response body element type
Returns:
  a mono containing the body, or a `WebClientResponseException` if the status code is 4xx or 5xx

#### bodyToFlux

    <T> reactor.core.publisher.Flux<T> bodyToFlux(Class<T> elementClass)

Extract the body to a `Flux`. By default, if the response has status code 4xx or 5xx, the `Flux` will contain a `WebClientException`. This can be overridden with `onStatus(Predicate, Function)`.

Type Parameters:
  `T` - the type of elements in the response
Parameters:
  `elementClass` - the class of elements in the response
Returns:
  a flux containing the body, or a `WebClientResponseException` if the status code is 4xx or 5xx

#### bodyToFlux

    <T> reactor.core.publisher.Flux<T> bodyToFlux(org.springframework.core.ParameterizedTypeReference<T> elementTypeRef)

Extract the body to a `Flux`. By default, if the response has status code 4xx or 5xx, the `Flux` will contain a `WebClientException`. This can be overridden with `onStatus(Predicate, Function)`.

Type Parameters:
  `T` - the type of elements in the response
Parameters:
  `elementTypeRef` - a type reference describing the expected response body element type
Returns:
  a flux containing the body, or a `WebClientResponseException` if the status code is 4xx or 5xx

#### toEntity

    <T> reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<T>> toEntity(Class<T> bodyClass)

Return the response as a delayed `ResponseEntity`. By default, if the response has status code 4xx or 5xx, the `Mono` will contain a `WebClientException`. This can be overridden with `onStatus(Predicate, Function)`.

Type Parameters:
  `T` - response body type
Parameters:
  `bodyClass` - the expected response body type
Returns:
  `Mono` with the `ResponseEntity`
Since:
  5.2

#### toEntity

    <T> reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<T>> toEntity(org.springframework.core.ParameterizedTypeReference<T> bodyTypeReference)

Return the response as a delayed `ResponseEntity`. By default, if the response has status code 4xx or 5xx, the `Mono` will contain a `WebClientException`. This can be overridden with `onStatus(Predicate, Function)`.

Type Parameters:
  `T` - response body type
Parameters:
  `bodyTypeReference` - a type reference describing the expected response body type
Returns:
  `Mono` with the `ResponseEntity`
Since:
  5.2

#### toEntityList

    <T> reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<List<T>>> toEntityList(Class<T> elementClass)

Return the response as a delayed list of `ResponseEntity`s. By default, if the response has status code 4xx or 5xx, the `Mono` will contain a `WebClientException`. This can be overridden with `onStatus(Predicate, Function)`.

Type Parameters:
  `T` - the type of elements in the list
Parameters:
  `elementClass` - the expected response body list element class
Returns:
  `Mono` with the list of `ResponseEntity`s
Since:
  5.2

#### toEntityList

    <T> reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<List<T>>> toEntityList(org.springframework.core.ParameterizedTypeReference<T> elementTypeRef)

Return the response as a delayed list of `ResponseEntity`s. By default, if the response has status code 4xx or 5xx, the `Mono` will contain a `WebClientException`. This can be overridden with `onStatus(Predicate, Function)`.

Type Parameters:
  `T` - the type of elements in the list
Parameters:
  `elementTypeRef` - the expected response body list element reference type
Returns:
  `Mono` with the list of `ResponseEntity`s
Since:
  5.2

#### toBodilessEntity

    reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<Void>> toBodilessEntity()

Return the response as a delayed `ResponseEntity` containing status and headers, but no body. By default, if the response has status code 4xx or 5xx, the `Mono` will contain a `WebClientException`. This can be overridden with `onStatus(Predicate, Function)`. Calling this method will release the body of the response.

Returns:
  `Mono` with the bodiless `ResponseEntity`
Since:
  5.2