#http-request #range #streaming #requests #tokio #ergonomically

streaming-http-range-client

A client for ergonomically streaming HTTP Range requests

5 releases (2 stable)

1.0.1 Jul 18, 2024
1.0.0 Jul 15, 2024
0.2.0 Jul 15, 2024
0.1.1 Dec 5, 2023
0.1.0 Dec 5, 2023

#233 in HTTP client

Download history 3/week @ 2024-12-05 7/week @ 2024-12-12

226 downloads per month
Used in geomedea

MIT/Apache

30KB
681 lines

streaming_http_range_client

A client for ergonomically streaming HTTP Range requests in Rust.

use streaming_http_range_client::HttpClient;
use tokio::io::AsyncReadExt;

use tokio;
let mut new_client = HttpClient::new("https://georust.org");
new_client.set_range(2..14).await.unwrap();

let mut output = String::new();
new_client.read_to_string(&mut output).await.unwrap();

// This `expected_text` may need to be updated someday if someone updates the site.
let expected_text = "DOCTYPE html";
assert_eq!(expected_text, output)

This crate was written primarily to serve the needs of https://github.com/michaelkirk/geomedea, but it might be more generally useful.

Dependencies

~6–21MB
~303K SLoC