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
  • Constructor Details

    • ClientResponseWrapper

      public ClientResponseWrapper(ClientResponse delegate)
      Create a new ClientResponseWrapper that wraps the given response.
      Parameters:
      delegate - the response to wrap
  • Method Details

    • response

      public ClientResponse response()
      Return the wrapped request.
    • statusCode

      public HttpstatusCode statusCode()
      Description copied from interface: ClientResponse
      Return the HTTP status code as an HttpstatusCode value.
      specified by:
      statusCode in interface ClientResponse
      Returns:
      the HTTP status as an HttpstatusCode value (never null)
    • headers

      public ClientResponse.Headers headers()
      Description copied from interface: ClientResponse
      Return the headers of this response.
      specified by:
      headers in interface ClientResponse
    • cookies

      public&nbsp;MultiValueMap<string, ResponseCookie>&nbsp;cookies()
      Description copied from interface:&nbsp;ClientResponse
      Return the cookies of this response.
      specified by:
      cookies&nbsp;in interface&nbsp;ClientResponse
    • strategies

      public&nbsp;Exchangestrategies&nbsp;strategies()
      Description copied from interface:&nbsp;ClientResponse
      Return the strategies used to convert the body of this response.
      specified by:
      strategies&nbsp;in interface&nbsp;ClientResponse
    • request

      public&nbsp;HttpRequest&nbsp;request()
      Description copied from interface:&nbsp;ClientResponse
      Return the request associated with the response.
      specified by:
      request&nbsp;in interface&nbsp;ClientResponse
    • body

      public&nbsp;<T>&nbsp;T&nbsp;body(BodyExtractor<T, ? super ClientHttpResponse>&nbsp;extractor)
      Description copied from interface:&nbsp;ClientResponse
      Extract the body with the given BodyExtractor.
      specified by:
      body&nbsp;in interface&nbsp;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&nbsp;<T>&nbsp;reactor.core.publisher.Mono<T>&nbsp;bodyToMono(Class<? extends T>&nbsp;elementClass)
      Description copied from interface:&nbsp;ClientResponse
      Extract the body to a Mono.
      specified by:
      bodyToMono&nbsp;in interface&nbsp;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&nbsp;<T>&nbsp;reactor.core.publisher.Mono<T>&nbsp;bodyToMono(ParameterizedTypeReference<T>&nbsp;elementTypeRef)
      Description copied from interface:&nbsp;ClientResponse
      Extract the body to a Mono.
      specified by:
      bodyToMono&nbsp;in interface&nbsp;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&nbsp;<T>&nbsp;reactor.core.publisher.Flux<T>&nbsp;bodyToFlux(Class<? extends T>&nbsp;elementClass)
      Description copied from interface:&nbsp;ClientResponse
      Extract the body to a Flux.
      specified by:
      bodyToFlux&nbsp;in interface&nbsp;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&nbsp;<T>&nbsp;reactor.core.publisher.Flux<T>&nbsp;bodyToFlux(ParameterizedTypeReference<T>&nbsp;elementTypeRef)
      Description copied from interface:&nbsp;ClientResponse
      Extract the body to a Flux.
      specified by:
      bodyToFlux&nbsp;in interface&nbsp;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&nbsp;reactor.core.publisher.Mono<Void>&nbsp;releaseBody()
      Description copied from interface:&nbsp;ClientResponse
      Release the body of this response.
      specified by:
      releaseBody&nbsp;in interface&nbsp;ClientResponse
      Returns:
      a completion signal
      see Also:
    • toBodilessEntity

      public&nbsp;reactor.core.publisher.Mono<ResponseEntity<Void>>&nbsp;toBodilessEntity()
      Description copied from interface:&nbsp;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&nbsp;in interface&nbsp;ClientResponse
      Returns:
      Mono with the bodiless ResponseEntity
    • toEntity

      public&nbsp;<T> reactor.core.publisher.Mono<ResponseEntity<T>>&nbsp;toEntity(Class<T>&nbsp;bodyType)
      Description copied from interface:&nbsp;ClientResponse
      Return this response as a delayed ResponseEntity.
      specified by:
      toEntity&nbsp;in interface&nbsp;ClientResponse
      Type Parameters:
      T - response body type
      Parameters:
      bodyType - the expected response body type
      Returns:
      Mono with the ResponseEntity
    • toEntity

      public&nbsp;<T> reactor.core.publisher.Mono<ResponseEntity<T>>&nbsp;toEntity(ParameterizedTypeReference<T>&nbsp;bodyTypeReference)
      Description copied from interface:&nbsp;ClientResponse
      Return this response as a delayed ResponseEntity.
      specified by:
      toEntity&nbsp;in interface&nbsp;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&nbsp;<T> reactor.core.publisher.Mono<ResponseEntity<List<T>>>&nbsp;toEntityList(Class<T>&nbsp;elementClass)
      Description copied from interface:&nbsp;ClientResponse
      Return this response as a delayed list of ResponseEntitys.
      specified by:
      toEntityList&nbsp;in interface&nbsp;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 ResponseEntitys
    • toEntityList

      public&nbsp;<T> reactor.core.publisher.Mono<ResponseEntity<List<T>>>&nbsp;toEntityList(ParameterizedTypeReference<T>&nbsp;elementTypeRef)
      Description copied from interface:&nbsp;ClientResponse
      Return this response as a delayed list of ResponseEntitys.
      specified by:
      toEntityList&nbsp;in interface&nbsp;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 ResponseEntitys
    • createException

      public&nbsp;reactor.core.publisher.Mono<WebClientResponseException>&nbsp;createException()
      Description copied from interface:&nbsp;ClientResponse
      Create a WebClientResponseException that contains the response status, headers, body, and the originating request.
      specified by:
      createException&nbsp;in interface&nbsp;ClientResponse
      Returns:
      a Mono with the created exception
    • createError

      public&nbsp;<T>&nbsp;reactor.core.publisher.Mono<T>&nbsp;createError()
      Description copied from interface:&nbsp;ClientResponse
      Create a Mono that terminates with a WebClientResponseException, containing the response status, headers, body, and the originating request.
      specified by:
      createError&nbsp;in interface&nbsp;ClientResponse
      Type Parameters:
      T - the reified type
      Returns:
      a Mono that fails with a WebClientResponseException.
      see Also:
    • logPrefix

      public&nbsp;string&nbsp;logPrefix()
      Description copied from interface:&nbsp;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&nbsp;in interface&nbsp;ClientResponse
      Returns:
      the log message prefix or an empty string if the LOG_ID_ATTRIBUTE is not set