Crates.io | ds-http-client |
lib.rs | ds-http-client |
version | 0.1.0 |
source | src |
created_at | 2024-09-20 23:09:18.453186 |
updated_at | 2024-09-20 23:09:18.453186 |
description | HTTP client to download files or query API with User-Agent set |
homepage | |
repository | |
max_upload_size | |
id | 1381846 |
size | 6,438 |
The crate ds-http-client is a HTTP client based on Hyper / reqwest components.
It can be used to download a file on an HTTP server, or query an API with User-Agent header.
```
use ds_http_client::Client;
let mut headers = HashMap::new();
headers.insert(
"User-Agent".to_string(),
"foo/1.2.3".to_string(),
);
let client = Client::new(Some(headers));
```
```
let url = "http://www.example.com/example.tar.gz";
let target_path = "/tmp/example.tar.gz";
if let Err(error) = client().download(&url, &target_path).await {
eprintln!("Can't download file: {:?}", error);
}
```