public class ResourceHttpMessageWriter extends AbstractServerHttpMessageWriter<org.springframework.core.io.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,
org.springframework.core.io.Resource resource,
MediaType mediaType) |
protected Map<String,Object> |
resolveWriteHints(org.springframework.core.ResolvableType streamType,
org.springframework.core.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 org.springframework.core.io.Resource> inputStream,
org.springframework.core.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 org.springframework.core.io.Resource> inputStream,
org.springframework.core.ResolvableType streamType,
org.springframework.core.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, getWritableMediaTypespublic static final String HTTP_RANGE_REQUEST_HINT
public ResourceHttpMessageWriter()
public ResourceHttpMessageWriter(int bufferSize)
protected Map<String,Object> resolveWriteHints(org.springframework.core.ResolvableType streamType, org.springframework.core.ResolvableType elementType, MediaType mediaType, ServerHttpRequest request)
AbstractServerHttpMessageWriterAbstractServerHttpMessageWriter.write(Publisher, ResolvableType, ResolvableType, MediaType, ServerHttpRequest, ServerHttpResponse, Map).resolveWriteHints in class AbstractServerHttpMessageWriter<org.springframework.core.io.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 org.springframework.core.io.Resource> inputStream, org.springframework.core.ResolvableType elementType, MediaType mediaType, ReactiveHttpOutputMessage outputMessage, Map<String,Object> hints)
HttpMessageWriterwrite in interface HttpMessageWriter<org.springframework.core.io.Resource>write in class AbstractServerHttpMessageWriter<org.springframework.core.io.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 org.springframework.core.io.Resource> inputStream, org.springframework.core.ResolvableType streamType, org.springframework.core.ResolvableType elementType, MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response, Map<String,Object> hints)
ServerHttpMessageWriterwrite in interface ServerHttpMessageWriter<org.springframework.core.io.Resource>write in class AbstractServerHttpMessageWriter<org.springframework.core.io.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, org.springframework.core.io.Resource resource, MediaType mediaType)