#async-http #range #requests #http-request #streaming #reading #memory

async_http_range_reader

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

8 releases (5 breaking)

0.7.1 Apr 10, 2024
0.7.0 Feb 23, 2024
0.6.1 Feb 17, 2024
0.5.0 Jan 30, 2024
0.1.0 Oct 22, 2023

#43 in Caching

Download history 104/week @ 2024-01-01 151/week @ 2024-01-08 205/week @ 2024-01-15 74/week @ 2024-01-22 325/week @ 2024-01-29 312/week @ 2024-02-05 1413/week @ 2024-02-12 1594/week @ 2024-02-19 1437/week @ 2024-02-26 1427/week @ 2024-03-04 1270/week @ 2024-03-11 1706/week @ 2024-03-18 2183/week @ 2024-03-25 2803/week @ 2024-04-01 1700/week @ 2024-04-08 2302/week @ 2024-04-15

9,136 downloads per month
Used in 2 crates (via rattler_installs_packages)

MIT license

46KB
825 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

~7–20MB
~276K SLoC