micronaut-core
micronaut-core copied to clipboard
Support for HTTP 206 Partial Content for serving SystemFile
Feature description
Current NettySystemFileCustomizableResponseType
implementation does not support partial content.
Its support may be useful for building something like a video streaming service.
I made my own implementation of NettyFileCustomizableResponseType
based on copy-paste from NettySystemFileCustomizableResponseType
https://gist.github.com/Ksnz/b2a223262514fe77218d481aa7ed6d96
And now endpoint wrapped into it like
@Get(value = "{id}", produces = MediaType.ALL)
public ByteRangeSupportNettySystemFileCustomizableResponseType fetchPreview(@PathVariable UUID id)
{
...
return new ByteRangeSupportNettySystemFileCustomizableResponseType(new SystemFile(file));
}
supports requests with byte-range.
My implementation isn't perfect because I just need to solve a problem and have no clue how to properly deal with invalid range exceptions. So it requires some refactoring to be used in framework.