HTTP Client Utilities
A convenient HTTP client library for Rust with support for:
- Simple API for making HTTP requests (GET, POST, etc.)
- Query parameters and headers support
- File downloads with progress reporting
- Resumable downloads
- JSON serialization/deserialization
Examples
use http_client_utils::HttpClient;
use std::path::Path;
#[tokio::main]
async fn main() {
// Simple GET request
let client = HttpClient::new();
let response = client.get("https://httpbin.org/get").await.unwrap();
println!("Status: {}", response.status());
// File download with progress
client.download_file(
"https://example.com/file.zip",
Path::new("file.zip"),
|downloaded, total| {
println!("Downloaded: {}/{} bytes", downloaded, total);
}
).await.unwrap();
// Resumable download
client.download_file_with_resume(
"https://example.com/large-file.zip",
Path::new("large-file.zip"),
|downloaded, total| {
let percent = (downloaded as f64 / total as f64) * 100.0;
println!("Progress: {:.1}%", percent);
}
).await.unwrap();
}