surf icon indicating copy to clipboard operation
surf copied to clipboard

Provide AsyncSeek on body reader.

Open sagudev opened this issue 4 years ago • 0 comments

Currently there is no elegant way to seek through data stream, except using range headers manually. So I purpose adding AsyncSeek, that would provide seek method on body reader. The seek method would fail if response contains Accept-Ranges: none. In other cases the reader would actually send new request with appropriate Range header.

On SeekFrom::Start(x) the range header should look like Range: bytes={x}-, so the reader can read till the end of stream normally. For SeekFrom::Current(x) is similar to upper example: Range: bytes={c+x}-; where c is current stream position. For SeekFrom::End(x) we just get the last x bytes: Range: bytes=-{x}.

sagudev avatar Oct 18 '21 04:10 sagudev