Class SystemFileBodyWriter
java.lang.Object
io.micronaut.http.server.netty.body.SystemFileBodyWriter
- All Implemented Interfaces:
MessageBodyWriter<SystemFile>,ResponseBodyWriter<SystemFile>
@Singleton
@Internal
public final class SystemFileBodyWriter
extends Object
implements ResponseBodyWriter<SystemFile>
Body writer for
SystemFiles.- Since:
- 4.0.0
- Author:
- Graeme Rocher
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final NettyHttpServerConfiguration.FileTypeHandlerConfiguration -
Constructor Summary
ConstructorsConstructorDescriptionSystemFileBodyWriter(NettyHttpServerConfiguration.FileTypeHandlerConfiguration configuration, ExecutorService ioExecutor) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanhandleIfModifiedAndHeaders(HttpRequest<?> request, MutableHttpResponse<?> response, FileCustomizableResponseType systemFile, MutableHttpResponse<?> nettyResponse) protected ByteBodyHttpResponse<?>notModified(MutableHttpResponse<?> originalResponse) protected voidsetDateAndCacheHeaders(MutableHttpResponse response, long lastModified) protected voidsetDateHeader(MutableHttpResponse response) write(ByteBufferFactory<?, ?> bufferFactory, HttpRequest<?> request, @NonNull MutableHttpResponse<SystemFile> httpResponse, @NonNull Argument<SystemFile> type, @NonNull MediaType mediaType, SystemFile object) Writes an object as aByteBodyHttpResponse.write(HttpRequest<?> request, MutableHttpResponse<SystemFile> response, SystemFile systemFile) voidwriteTo(Argument<SystemFile> type, MediaType mediaType, SystemFile file, 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, waitMethods inherited from interface io.micronaut.http.body.MessageBodyWriter
createSpecific, isBlocking, isWriteable, writeTo
-
Field Details
-
configuration
-
-
Constructor Details
-
SystemFileBodyWriter
public SystemFileBodyWriter(NettyHttpServerConfiguration.FileTypeHandlerConfiguration configuration, @Named("blocking") ExecutorService ioExecutor)
-
-
Method Details
-
writeTo
public void writeTo(Argument<SystemFile> type, MediaType mediaType, SystemFile file, MutableHeaders outgoingHeaders, OutputStream outputStream) throws CodecException Description copied from interface:MessageBodyWriterWrites an object to the given output stream.- Specified by:
writeToin interfaceMessageBodyWriter<SystemFile>- Parameters:
type- The typemediaType- The media typefile- The object to writeoutgoingHeaders- The HTTP headersoutputStream- The output stream- Throws:
CodecException- If an error occurs decoding
-
write
public ByteBodyHttpResponse<?> write(ByteBufferFactory<?, ?> bufferFactory, HttpRequest<?> request, @NonNull @NonNull MutableHttpResponse<SystemFile> httpResponse, @NonNull @NonNull Argument<SystemFile> type, @NonNull @NonNull MediaType mediaType, SystemFile object) throws CodecExceptionDescription copied from interface:ResponseBodyWriterWrites an object as aByteBodyHttpResponse.- Specified by:
writein interfaceResponseBodyWriter<SystemFile>- Parameters:
bufferFactory- The buffer factoryrequest- The requesthttpResponse- The responsetype- The response body typemediaType- The media typeobject- The object to write- Returns:
- A
ByteBodyHttpResponsewith the response bytes - Throws:
CodecException- If an error occurs encoding
-
write
public ByteBodyHttpResponse<?> write(HttpRequest<?> request, MutableHttpResponse<SystemFile> response, SystemFile systemFile) throws CodecException - Throws:
CodecException
-
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
-