Class ClientResponseWrapper
java.lang.Object
org.springframework.web.reactive.function.client.support.ClientResponseWrapper
- All Implemented Interfaces:
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 ClassesModifier and TypeClassDescriptionstatic classImplementation of theHeadersinterface that can be subclassed to adapt the headers in aexchange filter function.Nested classes/interfaces inherited from interface org.springframework.web.reactive.function.client.ClientResponse
ClientResponse.Builder, ClientResponse.Headers -
Constructor Summary
ConstructorsConstructorDescriptionClientResponseWrapper(ClientResponse delegate) Create a newClientResponseWrapperthat wraps the given response. -
Method Summary
Modifier and TypeMethodDescription<T> Tbody(BodyExtractor<T, ? super ClientHttpResponse> extractor) Extract the body with the givenBodyExtractor.<T> reactor.core.publisher.Flux<T>bodyToFlux(Class<? extends T> elementClass) Extract the body to aFlux.<T> reactor.core.publisher.Flux<T>bodyToFlux(ParameterizedTypeReference<T> elementTypeRef) Extract the body to aFlux.<T> reactor.core.publisher.Mono<T>bodyToMono(Class<? extends T> elementClass) Extract the body to aMono.<T> reactor.core.publisher.Mono<T>bodyToMono(ParameterizedTypeReference<T> elementTypeRef) Extract the body to aMono.cookies()Return the cookies of this response.<T> reactor.core.publisher.Mono<T>Create aMonothat terminates with aWebClientResponseException, containing the response status, headers, body, and the originating request.reactor.core.publisher.Mono<WebClientResponseException>Create aWebClientResponseExceptionthat contains the response status, headers, body, and the originating request.headers()Return the headers of this response.Return a log message prefix to use to correlate messages for this exchange.intReturn the (potentially non-standard) status code of this response.reactor.core.publisher.Mono<Void>Release the body of this response.response()Return the wrapped request.Return the HTTP status code as anHttpStatusenum value.Return the strategies used to convert the body of this response.reactor.core.publisher.Mono<ResponseEntity<Void>>Return this response as a delayedResponseEntitycontaining status and headers, but no body.<T> reactor.core.publisher.Mono<ResponseEntity<T>>Return this response as a delayedResponseEntity.<T> reactor.core.publisher.Mono<ResponseEntity<T>>toEntity(ParameterizedTypeReference<T> bodyTypeReference) Return this response as a delayedResponseEntity.<T> reactor.core.publisher.Mono<ResponseEntity<List<T>>>toEntityList(Class<T> elementClass) Return this response as a delayed list ofResponseEntitys.<T> reactor.core.publisher.Mono<ResponseEntity<List<T>>>toEntityList(ParameterizedTypeReference<T> elementTypeRef) Return this response as a delayed list ofResponseEntitys.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.web.reactive.function.client.ClientResponse
mutate
-
Constructor Details
-
ClientResponseWrapper
Create a newClientResponseWrapperthat wraps the given response.- Parameters:
delegate- the response to wrap
-
-
Method Details
-
response
Return the wrapped request. -
strategies
Description copied from interface:ClientResponseReturn the strategies used to convert the body of this response.- Specified by:
strategiesin interfaceClientResponse
-
statusCode
Description copied from interface:ClientResponseReturn the HTTP status code as anHttpStatusenum value.- Specified by:
statusCodein interfaceClientResponse- Returns:
- the HTTP status as an HttpStatus enum value (never
null) - See Also:
-
rawStatusCode
public int rawStatusCode()Description copied from interface:ClientResponseReturn the (potentially non-standard) status code of this response.- Specified by:
rawStatusCodein interfaceClientResponse- Returns:
- the HTTP status as an integer value
- See Also:
-
headers
Description copied from interface:ClientResponseReturn the headers of this response.- Specified by:
headersin interfaceClientResponse
-
cookies
Description copied from interface:ClientResponseReturn the cookies of this response.- Specified by:
cookiesin interfaceClientResponse
-
body
Description copied from interface:ClientResponseExtract the body with the givenBodyExtractor.- Specified by:
bodyin interfaceClientResponse- Type Parameters:
T- the type of the body returned- Parameters:
extractor- theBodyExtractorthat reads from the response- Returns:
- the extracted body
-
bodyToMono
Description copied from interface:ClientResponseExtract the body to aMono.- Specified by:
bodyToMonoin interfaceClientResponse- Type Parameters:
T- the element type- Parameters:
elementClass- the class of element in theMono- Returns:
- a mono containing the body of the given type
T
-
bodyToMono
Description copied from interface:ClientResponseExtract the body to aMono.- Specified by:
bodyToMonoin interfaceClientResponse- Type Parameters:
T- the element type- Parameters:
elementTypeRef- the type reference of element in theMono- Returns:
- a mono containing the body of the given type
T
-
bodyToFlux
Description copied from interface:ClientResponseExtract the body to aFlux.- Specified by:
bodyToFluxin interfaceClientResponse- Type Parameters:
T- the element type- Parameters:
elementClass- the class of elements in theFlux- Returns:
- a flux containing the body of the given type
T
-
bodyToFlux
Description copied from interface:ClientResponseExtract the body to aFlux.- Specified by:
bodyToFluxin interfaceClientResponse- Type Parameters:
T- the element type- Parameters:
elementTypeRef- the type reference of elements in theFlux- Returns:
- a flux containing the body of the given type
T
-
releaseBody
Description copied from interface:ClientResponseRelease the body of this response.- Specified by:
releaseBodyin interfaceClientResponse- Returns:
- a completion signal
- See Also:
-
toBodilessEntity
Description copied from interface:ClientResponseReturn this response as a delayedResponseEntitycontaining status and headers, but no body. Calling this method will release the body of the response.- Specified by:
toBodilessEntityin interfaceClientResponse- Returns:
Monowith the bodilessResponseEntity
-
toEntity
Description copied from interface:ClientResponseReturn this response as a delayedResponseEntity.- Specified by:
toEntityin interfaceClientResponse- Type Parameters:
T- response body type- Parameters:
bodyType- the expected response body type- Returns:
Monowith theResponseEntity
-
toEntity
public <T> reactor.core.publisher.Mono<ResponseEntity<T>> toEntity(ParameterizedTypeReference<T> bodyTypeReference) Description copied from interface:ClientResponseReturn this response as a delayedResponseEntity.- Specified by:
toEntityin interfaceClientResponse- Type Parameters:
T- response body type- Parameters:
bodyTypeReference- a type reference describing the expected response body type- Returns:
Monowith theResponseEntity
-
toEntityList
Description copied from interface:ClientResponseReturn this response as a delayed list ofResponseEntitys.- Specified by:
toEntityListin interfaceClientResponse- Type Parameters:
T- the type of elements in the list- Parameters:
elementClass- the expected response body list element class- Returns:
Monowith the list ofResponseEntitys
-
toEntityList
public <T> reactor.core.publisher.Mono<ResponseEntity<List<T>>> toEntityList(ParameterizedTypeReference<T> elementTypeRef) Description copied from interface:ClientResponseReturn this response as a delayed list ofResponseEntitys.- Specified by:
toEntityListin interfaceClientResponse- Type Parameters:
T- the type of elements in the list- Parameters:
elementTypeRef- the expected response body list element reference type- Returns:
Monowith the list ofResponseEntitys
-
createException
Description copied from interface:ClientResponseCreate aWebClientResponseExceptionthat contains the response status, headers, body, and the originating request.- Specified by:
createExceptionin interfaceClientResponse- Returns:
- a
Monowith the created exception
-
createError
public <T> reactor.core.publisher.Mono<T> createError()Description copied from interface:ClientResponseCreate aMonothat terminates with aWebClientResponseException, containing the response status, headers, body, and the originating request.- Specified by:
createErrorin interfaceClientResponse- Type Parameters:
T- the reified type- Returns:
- a
Monothat fails with aWebClientResponseException. - See Also:
-
logPrefix
Description copied from interface:ClientResponseReturn 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_ATTRIBUTErequest attribute, further surrounded with "[" and "]".- Specified by:
logPrefixin interfaceClientResponse- Returns:
- the log message prefix or an empty String if the
LOG_ID_ATTRIBUTEis not set
-