public class ResourceHttpMessageWriter extends AbstractServerHttpMessageWriter<Resource>
HttpMessageWriter
that can write
Resources
.
For a Resource reader simply use ResourceDecoder
wrapped with
DecoderHttpMessageReader
.
Modifier and Type | Field and Description |
---|---|
static String |
HTTP_RANGE_REQUEST_HINT |
Constructor and Description |
---|
ResourceHttpMessageWriter() |
ResourceHttpMessageWriter(int bufferSize) |
Modifier and Type | Method and Description |
---|---|
protected void |
addHeaders(HttpHeaders headers,
Resource resource,
MediaType mediaType) |
protected Map<String,Object> |
resolveWriteHints(ResolvableType streamType,
ResolvableType elementType,
MediaType mediaType,
ServerHttpRequest request)
Invoked before writing the response to resolve hints by
AbstractServerHttpMessageWriter.write(Publisher, ResolvableType, ResolvableType, MediaType, ServerHttpRequest, ServerHttpResponse, Map) . |
reactor.core.publisher.Mono<Void> |
write(org.reactivestreams.Publisher<? extends Resource> inputStream,
ResolvableType elementType,
MediaType mediaType,
ReactiveHttpOutputMessage outputMessage,
Map<String,Object> hints)
Write an given object to the given output message.
|
reactor.core.publisher.Mono<Void> |
write(org.reactivestreams.Publisher<? extends Resource> inputStream,
ResolvableType streamType,
ResolvableType elementType,
MediaType mediaType,
ServerHttpRequest request,
ServerHttpResponse response,
Map<String,Object> hints)
Write a given object to the given output message with additional server related
parameters which could be used to create some hints or set the response status for example.
|
canWrite, getWritableMediaTypes
public static final String HTTP_RANGE_REQUEST_HINT
public ResourceHttpMessageWriter()
public ResourceHttpMessageWriter(int bufferSize)
protected Map<String,Object> resolveWriteHints(ResolvableType streamType, ResolvableType elementType, MediaType mediaType, ServerHttpRequest request)
AbstractServerHttpMessageWriter
AbstractServerHttpMessageWriter.write(Publisher, ResolvableType, ResolvableType, MediaType, ServerHttpRequest, ServerHttpResponse, Map)
.resolveWriteHints
in class AbstractServerHttpMessageWriter<Resource>
streamType
- the original type used for the method return value. For annotation
based controllers, the MethodParameter
is available via ResolvableType.getSource()
.elementType
- the stream element type to processmediaType
- the content type to use when writing. May be null
to
indicate that the default content type of the converter must be used.request
- the current HTTP requestpublic reactor.core.publisher.Mono<Void> write(org.reactivestreams.Publisher<? extends Resource> inputStream, ResolvableType elementType, MediaType mediaType, ReactiveHttpOutputMessage outputMessage, Map<String,Object> hints)
HttpMessageWriter
write
in interface HttpMessageWriter<Resource>
write
in class AbstractServerHttpMessageWriter<Resource>
inputStream
- the input stream to writeelementType
- the stream element type to process. This type must have previously
been passed to the HttpMessageWriter.canWrite(org.springframework.core.ResolvableType, org.springframework.http.MediaType)
canWrite} method of this interface, which must
have returned true
.mediaType
- the content type to use when writing, typically the value of an
Accept
header. May be null
to indicate that the default content
type of the converter must be used.outputMessage
- the message to write tohints
- additional information about how to writeMono
that indicates completion or errorpublic reactor.core.publisher.Mono<Void> write(org.reactivestreams.Publisher<? extends Resource> inputStream, ResolvableType streamType, ResolvableType elementType, MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response, Map<String,Object> hints)
ServerHttpMessageWriter
write
in interface ServerHttpMessageWriter<Resource>
write
in class AbstractServerHttpMessageWriter<Resource>
streamType
- the original type used for the method return value. For annotation
based controllers, the MethodParameter
is available via ResolvableType.getSource()
.
Can be null
.elementType
- the stream element type to processmediaType
- the content type to use when writing. May be null
to
indicate that the default content type of the converter must be used.request
- the current HTTP requestresponse
- the current HTTP responseMono
that indicates completion or errorprotected void addHeaders(HttpHeaders headers, Resource resource, MediaType mediaType)