#http-request #http #buffer #reader

http-range-client

HTTP client for HTTP Range requests with a buffer optimized for sequential requests

5 unstable releases

0.8.0 Aug 12, 2024
0.7.2 Sep 10, 2023
0.7.1 Sep 2, 2023
0.7.0 Aug 31, 2023
0.6.0 Nov 10, 2021

#98 in HTTP client

Download history 99/week @ 2024-07-28 128/week @ 2024-08-04 376/week @ 2024-08-11 168/week @ 2024-08-18 157/week @ 2024-08-25 498/week @ 2024-09-01 264/week @ 2024-09-08 162/week @ 2024-09-15 113/week @ 2024-09-22 67/week @ 2024-09-29 55/week @ 2024-10-06 74/week @ 2024-10-13 39/week @ 2024-10-20 42/week @ 2024-10-27 127/week @ 2024-11-03 278/week @ 2024-11-10

491 downloads per month
Used in 4 crates

MIT/Apache

35KB
647 lines

http-range-client

CI build crates.io version docs.rs docs

HTTP client for HTTP Range requests with a buffer optimized for sequential reading.

Implements Seek+Read for blocking clients, which makes it a drop-in replacement for local files.

Usage examples

use http_range_client::*;

let mut client = BufferedHttpRangeClient::new("https://flatgeobuf.org/test/data/countries.fgb");
let bytes = client.min_req_size(256).get_range(0, 3).await?;
assert_eq!(bytes, b"fgb");
let version = client.get_bytes(1).await?; // From buffer - no HTTP request!
assert_eq!(version, [3]);

let mut reader = HttpReader::new("https://www.rust-lang.org/static/images/favicon-32x32.png");
reader.seek(SeekFrom::Start(1)).ok();
let mut bytes = [0; 3];
reader.read_exact(&mut bytes)?;
assert_eq!(&bytes, b"PNG");

Supported HTTP clients (feature flag)

  • reqwest async (reqwest-async, default)
  • reqwest blocking (reqwest-sync, default): Not supported on Wasm target
  • ureq blocking (ureq-sync): Not supported on Wasm target

Other clients can be used via the AsyncBufferedHttpRangeClient resp. SyncBufferedHttpRangeClient adapter, after implementing the AsyncHttpRangeClient resp. SyncHttpRangeClient trait.

Dependencies

~0.5–14MB
~178K SLoC