Top Description Inners Fields Constructors Methods
org.springframework.web.reactive.function.client.support

public Class ClientResponseWrapper

extends Object
implements ClientResponse
Class Inheritance
All Implemented Interfaces
org.springframework.web.reactive.function.client.ClientResponse
Imports
java.util.List, .Optional, .OptionalLong, reactor.core.publisher.Flux, .Mono, org.springframework.core.ParameterizedTypeReference, org.springframework.http.HttpHeaders, .HttpRequest, .HttpStatusCode, .MediaType, .ResponseCookie, .ResponseEntity, org.springframework.http.client.reactive.ClientHttpResponse, org.springframework.util.Assert, .MultiValueMap, org.springframework.web.reactive.function.BodyExtractor, org.springframework.web.reactive.function.client.ClientResponse, .ExchangeStrategies, .WebClientResponseException

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.
Author
Arjen Poutsma
Since
5.0.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ClientResponseWrapper.HeadersWrapper

Implementation of the Headers interface that can be subclassed to adapt the headers in a exchange filter function.

Field Summary

Modifier and TypeField and Description
private final ClientResponse

Constructor Summary

AccessConstructor and Description
public
ClientResponseWrapper(ClientResponse
the response to wrap
delegate
)

Create a new ClientResponseWrapper that wraps the given response.

Method Summary

Modifier and TypeMethod and Description
public <T> T
body(BodyExtractor<T, ? super ClientHttpResponse>
the BodyExtractor that reads from the response
extractor
)

Implements org.springframework.web.reactive.function.client.ClientResponse.body.

Extract the body with the given BodyExtractor.

public <T> Flux<T>
bodyToFlux(Class<? extends T>
the class of elements in the Flux
elementClass
)

Implements org.springframework.web.reactive.function.client.ClientResponse.bodyToFlux.

Extract the body to a Flux.

public <T> Flux<T>
bodyToFlux(ParameterizedTypeReference<T>
the type reference of elements in the Flux
elementTypeRef
)

Implements org.springframework.web.reactive.function.client.ClientResponse.bodyToFlux.

Extract the body to a Flux.

public <T> Mono<T>
bodyToMono(Class<? extends T>
the class of element in the Mono
elementClass
)

Implements org.springframework.web.reactive.function.client.ClientResponse.bodyToMono.

Extract the body to a Mono.

public <T> Mono<T>
bodyToMono(ParameterizedTypeReference<T>
the type reference of element in the Mono
elementTypeRef
)

Implements org.springframework.web.reactive.function.client.ClientResponse.bodyToMono.

Extract the body to a Mono.

public MultiValueMap<String, ResponseCookie>
cookies()

Implements org.springframework.web.reactive.function.client.ClientResponse.cookies.

Return the cookies of this response.

public <T> Mono<T>
createError()

Implements org.springframework.web.reactive.function.client.ClientResponse.createError.

Create a Mono that terminates with a WebClientResponseException, containing the response status, headers, body, and the originating request.

public Mono<WebClientResponseException>
createException()

Implements org.springframework.web.reactive.function.client.ClientResponse.createException.

Create a WebClientResponseException that contains the response status, headers, body, and the originating request.

public ClientResponse.Headers
headers()

Implements org.springframework.web.reactive.function.client.ClientResponse.headers.

Return the headers of this response.

public String
logPrefix()

Implements org.springframework.web.reactive.function.client.ClientResponse.logPrefix.

Return a log message prefix to use to correlate messages for this exchange.

public Mono<Void>
public HttpRequest
request()

Implements org.springframework.web.reactive.function.client.ClientResponse.request.

Return the request associated with the response.

public ClientResponse
response()

Return the wrapped request.

public HttpStatusCode
public ExchangeStrategies
strategies()

Implements org.springframework.web.reactive.function.client.ClientResponse.strategies.

Return the strategies used to convert the body of this response.

public Mono<ResponseEntity<Void>>
toBodilessEntity()

Implements org.springframework.web.reactive.function.client.ClientResponse.toBodilessEntity.

Return this response as a delayed ResponseEntity containing status and headers, but no body.

public <T> Mono<ResponseEntity<T>>
toEntity(Class<T>
the expected response body type
bodyType
)

Implements org.springframework.web.reactive.function.client.ClientResponse.toEntity.

Return this response as a delayed ResponseEntity.

public <T> Mono<ResponseEntity<T>>
toEntity(ParameterizedTypeReference<T>
a type reference describing the expected response body type
bodyTypeReference
)

Implements org.springframework.web.reactive.function.client.ClientResponse.toEntity.

Return this response as a delayed ResponseEntity.

public <T> Mono<ResponseEntity<List<T>>>
toEntityList(Class<T>
the expected response body list element class
elementClass
)

Implements org.springframework.web.reactive.function.client.ClientResponse.toEntityList.

Return this response as a delayed list of ResponseEntitys.

public <T> Mono<ResponseEntity<List<T>>>
toEntityList(ParameterizedTypeReference<T>
the expected response body list element reference type
elementTypeRef
)

Implements org.springframework.web.reactive.function.client.ClientResponse.toEntityList.

Return this response as a delayed list of ResponseEntitys.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

delegateback to summary
private final ClientResponse delegate

Constructor Detail

ClientResponseWrapperback to summary
public ClientResponseWrapper(ClientResponse delegate)

Create a new ClientResponseWrapper that wraps the given response.

Parameters
delegate:ClientResponse

the response to wrap

Method Detail

bodyback to summary
public <T> T body(BodyExtractor<T, ? super ClientHttpResponse> extractor)

Implements org.springframework.web.reactive.function.client.ClientResponse.body.

Doc from org.springframework.web.reactive.function.client.ClientResponse.body.

Extract the body with the given BodyExtractor.

Parameters
<T>
the type of the body returned
extractor:BodyExtractor<T, ? super ClientHttpResponse>

the BodyExtractor that reads from the response

Returns:T

the extracted body

Annotations
@Override
bodyToFluxback to summary
public <T> Flux<T> bodyToFlux(Class<? extends T> elementClass)

Implements org.springframework.web.reactive.function.client.ClientResponse.bodyToFlux.

Doc from org.springframework.web.reactive.function.client.ClientResponse.bodyToFlux.

Extract the body to a Flux.

Parameters
<T>
the element type
elementClass:Class<? extends T>

the class of elements in the Flux

Returns:Flux<T>

a flux containing the body of the given type T

Annotations
@Override
bodyToFluxback to summary
public <T> Flux<T> bodyToFlux(ParameterizedTypeReference<T> elementTypeRef)

Implements org.springframework.web.reactive.function.client.ClientResponse.bodyToFlux.

Doc from org.springframework.web.reactive.function.client.ClientResponse.bodyToFlux.

Extract the body to a Flux.

Parameters
<T>
the element type
elementTypeRef:ParameterizedTypeReference<T>

the type reference of elements in the Flux

Returns:Flux<T>

a flux containing the body of the given type T

Annotations
@Override
bodyToMonoback to summary
public <T> Mono<T> bodyToMono(Class<? extends T> elementClass)

Implements org.springframework.web.reactive.function.client.ClientResponse.bodyToMono.

Doc from org.springframework.web.reactive.function.client.ClientResponse.bodyToMono.

Extract the body to a Mono.

Parameters
<T>
the element type
elementClass:Class<? extends T>

the class of element in the Mono

Returns:Mono<T>

a mono containing the body of the given type T

Annotations
@Override
bodyToMonoback to summary
public <T> Mono<T> bodyToMono(ParameterizedTypeReference<T> elementTypeRef)

Implements org.springframework.web.reactive.function.client.ClientResponse.bodyToMono.

Doc from org.springframework.web.reactive.function.client.ClientResponse.bodyToMono.

Extract the body to a Mono.

Parameters
<T>
the element type
elementTypeRef:ParameterizedTypeReference<T>

the type reference of element in the Mono

Returns:Mono<T>

a mono containing the body of the given type T

Annotations
@Override
cookiesback to summary
public MultiValueMap<String, ResponseCookie> cookies()

Implements org.springframework.web.reactive.function.client.ClientResponse.cookies.

Doc from org.springframework.web.reactive.function.client.ClientResponse.cookies.

Return the cookies of this response.

Annotations
@Override
createErrorback to summary
public <T> Mono<T> createError()

Implements org.springframework.web.reactive.function.client.ClientResponse.createError.

Doc from org.springframework.web.reactive.function.client.ClientResponse.createError.

Create a Mono that terminates with a WebClientResponseException, containing the response status, headers, body, and the originating request.

Parameters
<T>
the reified type
Returns:Mono<T>

a Mono that fails with a WebClientResponseException.

Annotations
@Override
createExceptionback to summary
public Mono<WebClientResponseException> createException()

Implements org.springframework.web.reactive.function.client.ClientResponse.createException.

Doc from org.springframework.web.reactive.function.client.ClientResponse.createException.

Create a WebClientResponseException that contains the response status, headers, body, and the originating request.

Returns:Mono<WebClientResponseException>

a Mono with the created exception

Annotations
@Override
headersback to summary
public ClientResponse.Headers headers()

Implements org.springframework.web.reactive.function.client.ClientResponse.headers.

Doc from org.springframework.web.reactive.function.client.ClientResponse.headers.

Return the headers of this response.

Annotations
@Override
logPrefixback to summary
public String logPrefix()

Implements org.springframework.web.reactive.function.client.ClientResponse.logPrefix.

Doc from org.springframework.web.reactive.function.client.ClientResponse.logPrefix.

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 "]".

Returns:String

the log message prefix or an empty String if the LOG_ID_ATTRIBUTE is not set

Annotations
@Override
releaseBodyback to summary
public Mono<Void> releaseBody()

Implements org.springframework.web.reactive.function.client.ClientResponse.releaseBody.

Doc from org.springframework.web.reactive.function.client.ClientResponse.releaseBody.

Release the body of this response.

Returns:Mono<Void>

a completion signal

Annotations
@Override
requestback to summary
public HttpRequest request()

Implements org.springframework.web.reactive.function.client.ClientResponse.request.

Doc from org.springframework.web.reactive.function.client.ClientResponse.request.

Return the request associated with the response.

Annotations
@Override
responseback to summary
public ClientResponse response()

Return the wrapped request.

statusCodeback to summary
public HttpStatusCode statusCode()

Implements org.springframework.web.reactive.function.client.ClientResponse.statusCode.

Doc from org.springframework.web.reactive.function.client.ClientResponse.statusCode.

Return the HTTP status code as an HttpStatusCode value.

Returns:HttpStatusCode

the HTTP status as an HttpStatusCode value (never null)

Annotations
@Override
strategiesback to summary
public ExchangeStrategies strategies()

Implements org.springframework.web.reactive.function.client.ClientResponse.strategies.

Doc from org.springframework.web.reactive.function.client.ClientResponse.strategies.

Return the strategies used to convert the body of this response.

Annotations
@Override
toBodilessEntityback to summary
public Mono<ResponseEntity<Void>> toBodilessEntity()

Implements org.springframework.web.reactive.function.client.ClientResponse.toBodilessEntity.

Doc from org.springframework.web.reactive.function.client.ClientResponse.toBodilessEntity.

Return this response as a delayed ResponseEntity containing status and headers, but no body. Calling this method will release the body of the response.

Returns:Mono<ResponseEntity<Void>>

Mono with the bodiless ResponseEntity

Annotations
@Override
toEntityback to summary
public <T> Mono<ResponseEntity<T>> toEntity(Class<T> bodyType)

Implements org.springframework.web.reactive.function.client.ClientResponse.toEntity.

Doc from org.springframework.web.reactive.function.client.ClientResponse.toEntity.

Return this response as a delayed ResponseEntity.

Parameters
<T>
response body type
bodyType:Class<T>

the expected response body type

Returns:Mono<ResponseEntity<T>>

Mono with the ResponseEntity

Annotations
@Override
toEntityback to summary
public <T> Mono<ResponseEntity<T>> toEntity(ParameterizedTypeReference<T> bodyTypeReference)

Implements org.springframework.web.reactive.function.client.ClientResponse.toEntity.

Doc from org.springframework.web.reactive.function.client.ClientResponse.toEntity.

Return this response as a delayed ResponseEntity.

Parameters
<T>
response body type
bodyTypeReference:ParameterizedTypeReference<T>

a type reference describing the expected response body type

Returns:Mono<ResponseEntity<T>>

Mono with the ResponseEntity

Annotations
@Override
toEntityListback to summary
public <T> Mono<ResponseEntity<List<T>>> toEntityList(Class<T> elementClass)

Implements org.springframework.web.reactive.function.client.ClientResponse.toEntityList.

Doc from org.springframework.web.reactive.function.client.ClientResponse.toEntityList.

Return this response as a delayed list of ResponseEntitys.

Parameters
<T>
the type of elements in the list
elementClass:Class<T>

the expected response body list element class

Returns:Mono<ResponseEntity<List<T>>>

Mono with the list of ResponseEntitys

Annotations
@Override
toEntityListback to summary
public <T> Mono<ResponseEntity<List<T>>> toEntityList(ParameterizedTypeReference<T> elementTypeRef)

Implements org.springframework.web.reactive.function.client.ClientResponse.toEntityList.

Doc from org.springframework.web.reactive.function.client.ClientResponse.toEntityList.

Return this response as a delayed list of ResponseEntitys.

Parameters
<T>
the type of elements in the list
elementTypeRef:ParameterizedTypeReference<T>

the expected response body list element reference type

Returns:Mono<ResponseEntity<List<T>>>

Mono with the list of ResponseEntitys

Annotations
@Override
org.springframework.web.reactive.function.client.support back to summary

public Class ClientResponseWrapper.HeadersWrapper

extends Object
implements Headers
Class Inheritance
  • java.lang.Object
  • org.springframework.web.reactive.function.client.support.ClientResponseWrapper.HeadersWrapper
All Implemented Interfaces
org.springframework.web.reactive.function.client.ClientResponse.Headers

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

Field Summary

Modifier and TypeField and Description
private final ClientResponse.Headers

Constructor Summary

AccessConstructor and Description
public
HeadersWrapper(ClientResponse.Headers
the headers to wrap
headers
)

Create a new HeadersWrapper that wraps the given request.

Method Summary

Modifier and TypeMethod and Description
public HttpHeaders
public OptionalLong
contentLength()

Implements org.springframework.web.reactive.function.client.ClientResponse.Headers.contentLength.

Return the length of the body in bytes, as specified by the Content-Length header.

public Optional<MediaType>
contentType()

Implements org.springframework.web.reactive.function.client.ClientResponse.Headers.contentType.

Return the media type of the body, as specified by the Content-Type header.

public List<String>
header(String
the header name
headerName
)

Implements org.springframework.web.reactive.function.client.ClientResponse.Headers.header.

Return the header value(s), if any, for the header of the given name.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

headersback to summary
private final ClientResponse.Headers headers

Constructor Detail

HeadersWrapperback to summary
public HeadersWrapper(ClientResponse.Headers headers)

Create a new HeadersWrapper that wraps the given request.

Parameters
headers:ClientResponse.Headers

the headers to wrap

Method Detail

asHttpHeadersback to summary
public HttpHeaders asHttpHeaders()

Implements org.springframework.web.reactive.function.client.ClientResponse.Headers.asHttpHeaders.

Doc from org.springframework.web.reactive.function.client.ClientResponse.Headers.asHttpHeaders.

Return the headers as an HttpHeaders instance.

Annotations
@Override
contentLengthback to summary
public OptionalLong contentLength()

Implements org.springframework.web.reactive.function.client.ClientResponse.Headers.contentLength.

Doc from org.springframework.web.reactive.function.client.ClientResponse.Headers.contentLength.

Return the length of the body in bytes, as specified by the Content-Length header.

Annotations
@Override
contentTypeback to summary
public Optional<MediaType> contentType()

Implements org.springframework.web.reactive.function.client.ClientResponse.Headers.contentType.

Doc from org.springframework.web.reactive.function.client.ClientResponse.Headers.contentType.

Return the media type of the body, as specified by the Content-Type header.

Annotations
@Override
headerback to summary
public List<String> header(String headerName)

Implements org.springframework.web.reactive.function.client.ClientResponse.Headers.header.

Doc from org.springframework.web.reactive.function.client.ClientResponse.Headers.header.

Return the header value(s), if any, for the header of the given name.

Return an empty list if no header values are found.

Parameters
headerName:String

the header name

Annotations
@Override