Crates.io | http-range-client |
lib.rs | http-range-client |
version | 0.8.0 |
source | src |
created_at | 2021-11-10 22:28:36.634079 |
updated_at | 2024-08-12 21:41:13.90712 |
description | HTTP client for HTTP Range requests with a buffer optimized for sequential requests. |
homepage | https://github.com/pka/http-range-client |
repository | https://github.com/pka/http-range-client |
max_upload_size | |
id | 479909 |
size | 48,770 |
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.
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");
reqwest-async
, default)reqwest-sync
, default):
Not supported on Wasm targetureq-sync
):
Not supported on Wasm targetOther clients can be used via the AsyncBufferedHttpRangeClient
resp. SyncBufferedHttpRangeClient
adapter, after implementing the AsyncHttpRangeClient
resp. SyncHttpRangeClient
trait.