Class StreamFileBodyWriter
java.lang.Object
io.micronaut.http.server.netty.body.StreamFileBodyWriter
- All Implemented Interfaces:
MessageBodyWriter<StreamedFile>
,ResponseBodyWriter<StreamedFile>
@Singleton
@Internal
public final class StreamFileBodyWriter
extends Object
implements ResponseBodyWriter<StreamedFile>
Body writer for
StreamedFile
s.- Since:
- 4.0.0
- Author:
- Graeme Rocher
-
Field Summary
Modifier and TypeFieldDescriptionprotected final NettyHttpServerConfiguration.FileTypeHandlerConfiguration
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
handleIfModifiedAndHeaders
(HttpRequest<?> request, MutableHttpResponse<?> response, FileCustomizableResponseType systemFile, MutableHttpResponse<?> nettyResponse) protected ByteBodyHttpResponse<?>
notModified
(MutableHttpResponse<?> originalResponse) protected void
setDateAndCacheHeaders
(MutableHttpResponse response, long lastModified) protected void
setDateHeader
(MutableHttpResponse response) write
(ByteBufferFactory<?, ?> bufferFactory, HttpRequest<?> request, MutableHttpResponse<StreamedFile> outgoingResponse, Argument<StreamedFile> type, MediaType mediaType, StreamedFile object) Writes an object as aByteBodyHttpResponse
.void
writeTo
(Argument<StreamedFile> type, MediaType mediaType, StreamedFile object, MutableHeaders outgoingHeaders, OutputStream outputStream) Writes an object to the given output stream.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.http.body.MessageBodyWriter
createSpecific, isBlocking, isWriteable, writeTo
-
Field Details
-
configuration
-
-
Method Details
-
write
public ByteBodyHttpResponse<?> write(ByteBufferFactory<?, ?> bufferFactory, HttpRequest<?> request, MutableHttpResponse<StreamedFile> outgoingResponse, Argument<StreamedFile> type, MediaType mediaType, StreamedFile object) throws CodecExceptionDescription copied from interface:ResponseBodyWriter
Writes an object as aByteBodyHttpResponse
.- Specified by:
write
in interfaceResponseBodyWriter<StreamedFile>
- Parameters:
bufferFactory
- The buffer factoryrequest
- The requestoutgoingResponse
- The responsetype
- The response body typemediaType
- The media typeobject
- The object to write- Returns:
- A
ByteBodyHttpResponse
with the response bytes - Throws:
CodecException
- If an error occurs encoding
-
writeTo
public void writeTo(Argument<StreamedFile> type, MediaType mediaType, StreamedFile object, MutableHeaders outgoingHeaders, OutputStream outputStream) throws CodecException Description copied from interface:MessageBodyWriter
Writes an object to the given output stream.- Specified by:
writeTo
in interfaceMessageBodyWriter<StreamedFile>
- Parameters:
type
- The typemediaType
- The media typeobject
- The object to writeoutgoingHeaders
- The HTTP headersoutputStream
- The output stream- Throws:
CodecException
- If an error occurs decoding
-
handleIfModifiedAndHeaders
protected boolean handleIfModifiedAndHeaders(HttpRequest<?> request, MutableHttpResponse<?> response, FileCustomizableResponseType systemFile, MutableHttpResponse<?> nettyResponse) -
setDateAndCacheHeaders
- Parameters:
response
- The Http responselastModified
- The last modified
-
setDateHeader
- Parameters:
response
- The Http response
-
notModified
-