Supporting RangeResult for external resources

Hi,

I’m trying to serve Range responses for data that’s stored on an S3 bucket. I can of course get an InputStream and pass that to Play’s RangeResult.ofStream, but it means serving the whole file from S3 and having it drop the first N bytes, which is obviously inefficient for a range near the end of a large file. RangeResult.ofSource doesn’t help as it doesn’t start dropping until bytes are already received, too late to modify an S3 request.

My plan was to add an alternate version of ofSource that accepted a RangeSet => Source[ByteString, _] function, so that it could do the header parsing then generate a Source using whatever means (perhaps an Alpakka S3 Source, though it would be up to the caller). This might also be useful for local file serving as would be able to pass a start position to FileIO.fromPath.

Would that sound like a reasonable change to start work on? I’m not planning to add any specific support for Alpakka or S3 here, it would be quite generic for any Source that needed to know the start byte beforehand.