#async-http #http-request #http-file #range #streaming #requests #file-access

async_http_range_reader

A library for streaming reading of files over HTTP using range requests

11 releases (7 breaking)

0.9.1 Nov 12, 2024
0.8.0 May 7, 2024
0.7.0 Feb 23, 2024
0.3.0 Oct 26, 2023

#270 in Network programming

Download history 3941/week @ 2024-08-08 3310/week @ 2024-08-15 3829/week @ 2024-08-22 3622/week @ 2024-08-29 3260/week @ 2024-09-05 2364/week @ 2024-09-12 2661/week @ 2024-09-19 3165/week @ 2024-09-26 2999/week @ 2024-10-03 2787/week @ 2024-10-10 2799/week @ 2024-10-17 2981/week @ 2024-10-24 2766/week @ 2024-10-31 2683/week @ 2024-11-07 2876/week @ 2024-11-14 1943/week @ 2024-11-21

10,784 downloads per month
Used in 4 crates (2 directly)

MIT license

47KB
841 lines

Async HTTP Range Reader

Crates.io docs.rs GitHub Workflow Status (branch) GitHub

A crate that provides the AsyncHttpRangeReader struct, which allows streaming files over HTTP using range requests.


lib.rs:

This library provides the AsyncHttpRangeReader type.

It allows streaming a file over HTTP while also allow random access. The type implements both AsyncRead as well as AsyncSeek. This is supported through the use of range requests. Each individual read will request a portion of the file using an HTTP range request.

Requesting numerous small reads might turn out to be relatively slow because each reads needs to perform an HTTP request. To alleviate this issue AsyncHttpRangeReader::prefetch is provided. Using this method you can prefect a number of bytes which will be streamed in on the background. If a read operation is reading from already (pre)fetched ranges it will stream from the internal cache instead.

Internally the AsyncHttpRangeReader stores a memory map which allows sparsely reading the data into memory without actually requiring all memory for file to be resident in memory.

The primary use-case for this library is to be able to sparsely stream a zip archive over HTTP but its designed in a generic fashion.

Dependencies

~8–19MB
~243K SLoC