Skip to content

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

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

pka/http-range-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Languages