org.springframework.web.reactive.function.client.support

## Class ClientResponseWrapper

- java.lang.Object
- - org.springframework.web.reactive.function.client.support.ClientResponseWrapper

All Implemented Interfaces:
  ClientResponse

    public class ClientResponseWrapper
    extends Object
    implements ClientResponse

Implementation of the `ClientResponse` interface that can be subclassed to adapt the request in a `exchange filter function`. All methods default to calling through to the wrapped request.

Since:
  5.0.5
Author:
  Arjen Poutsma

### Nested Class Summary

Nested Classes
`static class` `ClientResponseWrapper.HeadersWrapper` Implementation of the `Headers` interface that can be subclassed to adapt the headers in a `exchange filter function`.

### Nested classes/interfaces inherited from interface org.springframework.web.reactive.function.client.ClientResponse

`ClientResponse.Builder, ClientResponse.Headers`

### Constructor Summary

Constructors
Constructor and Description
`ClientResponseWrapper(ClientResponse delegate)` Create a new `ClientResponseWrapper` that wraps the given response.

### Method Summary

All Methods Instance Methods Concrete Methods
`<T> T` `body(BodyExtractor<T,? super org.springframework.http.client.reactive.ClientHttpResponse> extractor)` Extract the body with the given `BodyExtractor`.
`<T> reactor.core.publisher.Flux<T>` `bodyToFlux(Class<? extends 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<? extends 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`.
`org.springframework.util.MultiValueMap<String,org.springframework.http.ResponseCookie>` `cookies()` Return the cookies of this response.
`reactor.core.publisher.Mono<WebClientResponseException>` `createException()` Create a `WebClientResponseException` that contains the response status, headers, body, and the originating request.
`ClientResponse.Headers` `headers()` Return the headers of this response.
`String` `logPrefix()` Return a log message prefix to use to correlate messages for this exchange.
`int` `rawStatusCode()` Return the (potentially non-standard) status code of this response.
`reactor.core.publisher.Mono<Void>` `releaseBody()` Release the body of this response.
`ClientResponse` `response()` Return the wrapped request.
`org.springframework.http.HttpStatus` `statusCode()` Return the HTTP status code as an `HttpStatus` enum value.
`ExchangeStrategies` `strategies()` Return the strategies used to convert the body of this response.
`reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<Void>>` `toBodilessEntity()` Return this 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> bodyType)` Return this response as a delayed `ResponseEntity`.
`<T> reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<T>>` `toEntity(org.springframework.core.ParameterizedTypeReference<T> bodyTypeReference)` Return this response as a delayed `ResponseEntity`.
`<T> reactor.core.publisher.Mono<org.springframework.http.ResponseEntity<List<T>>>` `toEntityList(Class<T> elementClass)` Return this 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 this response as a delayed list of `ResponseEntity`s.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.springframework.web.reactive.function.client.ClientResponse

`create, create, create, create, from`

### Constructor Detail

#### ClientResponseWrapper

    public ClientResponseWrapper(ClientResponse delegate)

Create a new `ClientResponseWrapper` that wraps the given response.

Parameters:
  `delegate` - the response to wrap

### Method Detail

#### response

    public ClientResponse response()

Return the wrapped request.

#### strategies

    public ExchangeStrategies strategies()

Description copied from interface: `ClientResponse`
Return the strategies used to convert the body of this response.

Specified by:
  `strategies` in interface `ClientResponse`

#### statusCode

    public org.springframework.http.HttpStatus statusCode()

Description copied from interface: `ClientResponse`
Return the HTTP status code as an `HttpStatus` enum value.

Specified by:
  `statusCode` in interface `ClientResponse`
Returns:
  the HTTP status as an HttpStatus enum value (never `null`)
See Also:
  `HttpStatus.valueOf(int)`

#### rawStatusCode

    public int rawStatusCode()

Description copied from interface: `ClientResponse`
Return the (potentially non-standard) status code of this response.

Specified by:
  `rawStatusCode` in interface `ClientResponse`
Returns:
  the HTTP status as an integer value
See Also:
  `ClientResponse.statusCode()`, `HttpStatus.resolve(int)`

#### headers

    public ClientResponse.Headers headers()

Description copied from interface: `ClientResponse`
Return the headers of this response.

Specified by:
  `headers` in interface `ClientResponse`

#### cookies

    public org.springframework.util.MultiValueMap<String,org.springframework.http.ResponseCookie> cookies()

Description copied from interface: `ClientResponse`
Return the cookies of this response.

Specified by:
  `cookies` in interface `ClientResponse`

#### body

    public <T> T body(BodyExtractor<T,? super org.springframework.http.client.reactive.ClientHttpResponse> extractor)

Description copied from interface: `ClientResponse`
Extract the body with the given `BodyExtractor`.

Specified by:
  `body` in interface `ClientResponse`
Type Parameters:
  `T` - the type of the body returned
Parameters:
  `extractor` - the `BodyExtractor` that reads from the response
Returns:
  the extracted body

#### bodyToMono

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

Description copied from interface: `ClientResponse`
Extract the body to a `Mono`.

Specified by:
  `bodyToMono` in interface `ClientResponse`
Type Parameters:
  `T` - the element type
Parameters:
  `elementClass` - the class of element in the `Mono`
Returns:
  a mono containing the body of the given type `T`

#### bodyToMono

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

Description copied from interface: `ClientResponse`
Extract the body to a `Mono`.

Specified by:
  `bodyToMono` in interface `ClientResponse`
Type Parameters:
  `T` - the element type
Parameters:
  `elementTypeRef` - the type reference of element in the `Mono`
Returns:
  a mono containing the body of the given type `T`

#### bodyToFlux

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

Description copied from interface: `ClientResponse`
Extract the body to a `Flux`.

Specified by:
  `bodyToFlux` in interface `ClientResponse`
Type Parameters:
  `T` - the element type
Parameters:
  `elementClass` - the class of elements in the `Flux`
Returns:
  a flux containing the body of the given type `T`

#### bodyToFlux

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

Description copied from interface: `ClientResponse`
Extract the body to a `Flux`.

Specified by:
  `bodyToFlux` in interface `ClientResponse`
Type Parameters:
  `T` - the element type
Parameters:
  `elementTypeRef` - the type reference of elements in the `Flux`
Returns:
  a flux containing the body of the given type `T`

#### releaseBody

    public reactor.core.publisher.Mono<Void> releaseBody()

Description copied from interface: `ClientResponse`
Release the body of this response.

Specified by:
  `releaseBody` in interface `ClientResponse`
Returns:
  a completion signal
See Also:
  `DataBufferUtils.release(DataBuffer)`

#### toBodilessEntity

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

Description copied from interface: `ClientResponse`
Return this response as a delayed `ResponseEntity` containing status and headers, but no body. Calling this method will release the body of the response.

Specified by:
  `toBodilessEntity` in interface `ClientResponse`
Returns:
  `Mono` with the bodiless `ResponseEntity`

#### toEntity

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

Description copied from interface: `ClientResponse`
Return this response as a delayed `ResponseEntity`.

Specified by:
  `toEntity` in interface `ClientResponse`
Type Parameters:
  `T` - response body type
Parameters:
  `bodyType` - the expected response body type
Returns:
  `Mono` with the `ResponseEntity`

#### toEntity

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

Description copied from interface: `ClientResponse`
Return this response as a delayed `ResponseEntity`.

Specified by:
  `toEntity` in interface `ClientResponse`
Type Parameters:
  `T` - response body type
Parameters:
  `bodyTypeReference` - a type reference describing the expected response body type
Returns:
  `Mono` with the `ResponseEntity`

#### toEntityList

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

Description copied from interface: `ClientResponse`
Return this response as a delayed list of `ResponseEntity`s.

Specified by:
  `toEntityList` in interface `ClientResponse`
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

#### toEntityList

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

Description copied from interface: `ClientResponse`
Return this response as a delayed list of `ResponseEntity`s.

Specified by:
  `toEntityList` in interface `ClientResponse`
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

#### createException

    public reactor.core.publisher.Mono<WebClientResponseException> createException()

Description copied from interface: `ClientResponse`
Create a `WebClientResponseException` that contains the response status, headers, body, and the originating request.

Specified by:
  `createException` in interface `ClientResponse`
Returns:
  a `Mono` with the created exception

#### logPrefix

    public String logPrefix()

Description copied from interface: `ClientResponse`
Return a log message prefix to use to correlate messages for this exchange.

The prefix is based on ClientRequest.logPrefix(), which itself is based on the value of the `LOG_ID_ATTRIBUTE` request attribute, further surrounded with "[" and "]".

Specified by:
  `logPrefix` in interface `ClientResponse`
Returns:
  the log message prefix or an empty String if the `LOG_ID_ATTRIBUTE` is not set