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

pack-priv Class DefaultClientResponse

extends Object
implements ClientResponse
Class Inheritance
All Implemented Interfaces
org.springframework.web.reactive.function.client.ClientResponse
Imports
java.nio.charset.Charset, java.util.Collections, .List, .Map, .Optional, .OptionalLong, java.util.function.Function, .Supplier, reactor.core.publisher.Flux, .Mono, org.springframework.core.ParameterizedTypeReference, .ResolvableType, org.springframework.core.codec.Decoder, .Hints, org.springframework.core.io.buffer.DataBuffer, .DataBufferUtils, .DefaultDataBufferFactory, org.springframework.http.HttpHeaders, .HttpRequest, .HttpStatus, .HttpStatusCode, .MediaType, .ResponseCookie, .ResponseEntity, org.springframework.http.client.reactive.ClientHttpResponse, org.springframework.http.codec.DecoderHttpMessageReader, .HttpMessageReader, org.springframework.http.server.reactive.ServerHttpResponse, org.springframework.lang.Nullable, org.springframework.util.Assert, .MimeType, .MultiValueMap, .ObjectUtils, org.springframework.web.reactive.function.BodyExtractor, .BodyExtractors

Default implementation of ClientResponse.
Authors
Arjen Poutsma, Brian Clozel
Since
5.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private final BodyExtractor.Context
private static final byte[]
private final ClientResponse.Headers
private final String
private final String
private final Supplier<HttpRequest>
private final ClientHttpResponse
private final ExchangeStrategies

Constructor Summary

AccessConstructor and Description
public
DefaultClientResponse(ClientHttpResponse response, ExchangeStrategies strategies, String logPrefix, String requestDescription, Supplier<HttpRequest> requestSupplier)

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.

private Function<ResolvableType, ?>
initDecodeFunction(byte[] body, MediaType contentType)

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 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

bodyExtractorContextback to summary
private final BodyExtractor.Context bodyExtractorContext
EMPTYback to summary
private static final byte[] EMPTY
headersback to summary
private final ClientResponse.Headers headers
logPrefixback to summary
private final String logPrefix
requestDescriptionback to summary
private final String requestDescription
requestSupplierback to summary
private final Supplier<HttpRequest> requestSupplier
responseback to summary
private final ClientHttpResponse response
strategiesback to summary
private final ExchangeStrategies strategies

Constructor Detail

DefaultClientResponseback to summary
public DefaultClientResponse(ClientHttpResponse response, ExchangeStrategies strategies, String logPrefix, String requestDescription, Supplier<HttpRequest> requestSupplier)

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
@SuppressWarnings:unchecked
@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
@SuppressWarnings:unchecked
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
initDecodeFunctionback to summary
private Function<ResolvableType, ?> initDecodeFunction(byte[] body, MediaType contentType)
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
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 back to summary

private Class DefaultClientResponse.DefaultHeaders

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

Field Summary

Modifier and TypeField and Description
private final HttpHeaders

Constructor Summary

AccessConstructor and Description
private

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.

private OptionalLong
toOptionalLong(long value)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

httpHeadersback to summary
private final HttpHeaders httpHeaders

Constructor Detail

DefaultHeadersback to summary
private DefaultHeaders()

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
toOptionalLongback to summary
private OptionalLong toOptionalLong(long value)