It would be nice if the Servlet spec would expose zero-copy file transfer operations, so that files can be written to the network socket without involving the CPU. In Java, zero-copy is exposed through the FileChannel::transferTo methods, but combing this channel-based API with the Servlet spec seems impossible.
For instance, this could take the form of a long transfer(Path file, long pos, long count) method on either ServletResponse or ServletOutputStream, that takes the file path, position and byte count, and returns the bytes written.
It would be nice if the Servlet spec would expose zero-copy file transfer operations, so that files can be written to the network socket without involving the CPU. In Java, zero-copy is exposed through the
FileChannel::transferTo
methods, but combing this channel-based API with the Servlet spec seems impossible.For instance, this could take the form of a
long transfer(Path file, long pos, long count)
method on eitherServletResponse
orServletOutputStream
, that takes the file path, position and byte count, and returns the bytes written.