Package org.springframework.http.codec
Class DecoderHttpMessageReader<T>
java.lang.Object
org.springframework.http.codec.DecoderHttpMessageReader<T>
- Type Parameters:
- T- the type of objects in the decoded output stream
- All Implemented Interfaces:
- HttpMessageReader<T>
- Direct Known Subclasses:
- ResourceHttpMessageReader
HttpMessageReader that wraps and delegates to a Decoder.
 Also a HttpMessageReader that pre-resolves decoding hints
 from the extra information available on the server side such as the request
 or controller method parameter annotations.
- Since:
- 5.0
- Author:
- Arjen Poutsma, Sebastien Deleuze, Rossen Stoyanchev
- 
Constructor SummaryConstructorsConstructorDescriptionDecoderHttpMessageReader(Decoder<T> decoder) Create an instance wrapping the givenDecoder.
- 
Method SummaryModifier and TypeMethodDescriptionbooleancanRead(ResolvableType elementType, MediaType mediaType) Whether the given object type is supported by this reader.protected MediaTypegetContentType(HttpMessage inputMessage) Determine the Content-Type of the HTTP message based on the "Content-Type" header or otherwise default toMediaType.APPLICATION_OCTET_STREAM.Return theDecoderof this reader.Return the list of media types supported by this reader.getReadableMediaTypes(ResolvableType elementType) Return the list of media types supported by this Reader for the given type of element.getReadHints(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response) Get additional hints for decoding for example based on the server request or annotations from controller method parameters.getReadHints(ResolvableType elementType, ReactiveHttpInputMessage message) Get additional hints for decoding based on the input HTTP message.reactor.core.publisher.Flux<T>read(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response, Map<String, Object> hints) Server-side only alternative toHttpMessageReader.read(ResolvableType, ReactiveHttpInputMessage, Map)with additional context available.reactor.core.publisher.Flux<T>read(ResolvableType elementType, ReactiveHttpInputMessage message, Map<String, Object> hints) Read from the input message and decode to a stream of objects.reactor.core.publisher.Mono<T>readMono(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response, Map<String, Object> hints) Server-side only alternative toHttpMessageReader.readMono(ResolvableType, ReactiveHttpInputMessage, Map)with additional, context available.reactor.core.publisher.Mono<T>readMono(ResolvableType elementType, ReactiveHttpInputMessage message, Map<String, Object> hints) Read from the input message and decode to a single object.
- 
Constructor Details- 
DecoderHttpMessageReaderCreate an instance wrapping the givenDecoder.
 
- 
- 
Method Details- 
getDecoderReturn theDecoderof this reader.
- 
getReadableMediaTypesDescription copied from interface:HttpMessageReaderReturn the list of media types supported by this reader. The list may not apply to every possible target element type and calls to this method should typically be guarded viacanWrite(elementType, null). The list may also exclude media types supported only for a specific element type. Alternatively, useHttpMessageReader.getReadableMediaTypes(ResolvableType)for a more precise list.- Specified by:
- getReadableMediaTypesin interface- HttpMessageReader<T>
- Returns:
- the general list of supported media types
 
- 
getReadableMediaTypesDescription copied from interface:HttpMessageReaderReturn the list of media types supported by this Reader for the given type of element. This list may differ fromHttpMessageReader.getReadableMediaTypes()if the Reader doesn't support the element type, or if it supports it only for a subset of media types.- Specified by:
- getReadableMediaTypesin interface- HttpMessageReader<T>
- Parameters:
- elementType- the type of element to read
- Returns:
- the list of media types supported for the given class
 
- 
canReadDescription copied from interface:HttpMessageReaderWhether the given object type is supported by this reader.- Specified by:
- canReadin interface- HttpMessageReader<T>
- Parameters:
- elementType- the type of object to check
- mediaType- the media type for the read (possibly- null)
- Returns:
- trueif readable,- falseotherwise
 
- 
readpublic reactor.core.publisher.Flux<T> read(ResolvableType elementType, ReactiveHttpInputMessage message, Map<String, Object> hints) Description copied from interface:HttpMessageReaderRead from the input message and decode to a stream of objects.- Specified by:
- readin interface- HttpMessageReader<T>
- Parameters:
- elementType- the type of objects in the stream which must have been previously checked via- HttpMessageReader.canRead(ResolvableType, MediaType)
- message- the message to read from
- hints- additional information about how to read and decode the input
- Returns:
- the decoded stream of elements
 
- 
readMonopublic reactor.core.publisher.Mono<T> readMono(ResolvableType elementType, ReactiveHttpInputMessage message, Map<String, Object> hints) Description copied from interface:HttpMessageReaderRead from the input message and decode to a single object.- Specified by:
- readMonoin interface- HttpMessageReader<T>
- Parameters:
- elementType- the type of objects in the stream which must have been previously checked via- HttpMessageReader.canRead(ResolvableType, MediaType)
- message- the message to read from
- hints- additional information about how to read and decode the input
- Returns:
- the decoded object
 
- 
getContentTypeDetermine the Content-Type of the HTTP message based on the "Content-Type" header or otherwise default toMediaType.APPLICATION_OCTET_STREAM.- Parameters:
- inputMessage- the HTTP message
- Returns:
- the MediaType, possibly null.
 
- 
getReadHintsprotected Map<String,Object> getReadHints(ResolvableType elementType, ReactiveHttpInputMessage message) Get additional hints for decoding based on the input HTTP message.- Since:
- 5.3
 
- 
readpublic reactor.core.publisher.Flux<T> read(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response, Map<String, Object> hints) Description copied from interface:HttpMessageReaderServer-side only alternative toHttpMessageReader.read(ResolvableType, ReactiveHttpInputMessage, Map)with additional context available.- Specified by:
- readin interface- HttpMessageReader<T>
- Parameters:
- actualType- the actual type of the target method parameter; for annotated controllers, the- MethodParametercan be accessed via- ResolvableType.getSource().
- elementType- the type of Objects in the output stream
- request- the current request
- response- the current response
- hints- additional information about how to read the body
- Returns:
- the decoded stream of elements
 
- 
readMonopublic reactor.core.publisher.Mono<T> readMono(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response, Map<String, Object> hints) Description copied from interface:HttpMessageReaderServer-side only alternative toHttpMessageReader.readMono(ResolvableType, ReactiveHttpInputMessage, Map)with additional, context available.- Specified by:
- readMonoin interface- HttpMessageReader<T>
- Parameters:
- actualType- the actual type of the target method parameter; for annotated controllers, the- MethodParametercan be accessed via- ResolvableType.getSource().
- elementType- the type of Objects in the output stream
- request- the current request
- response- the current response
- hints- additional information about how to read the body
- Returns:
- the decoded stream of elements
 
- 
getReadHintsprotected Map<String,Object> getReadHints(ResolvableType actualType, ResolvableType elementType, ServerHttpRequest request, ServerHttpResponse response) Get additional hints for decoding for example based on the server request or annotations from controller method parameters. By default, delegate to the decoder if it is an instance ofHttpMessageDecoder.
 
-