#user-agent

ds-http-client

HTTP client to download files or query API with User-Agent set

1 unstable release

0.1.0 Sep 20, 2024

#34 in #user-agent

Download history 40/week @ 2024-09-14 193/week @ 2024-09-21 27/week @ 2024-09-28 27/week @ 2024-10-05 435/week @ 2024-10-12 616/week @ 2024-10-19 3/week @ 2024-10-26 10/week @ 2024-11-02

1,073 downloads per month
Used in sparql-client

BSD-2-Clause

7KB
96 lines

HTTP client for Nasqueron Datasources components

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.

Usage example

Initialize a client

```
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));
```

Download a file

```
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);
}
```

lib.rs:

HTTP client

High-level interface to Hyper/reqwest HTTP client.

This library is optimized to work with Nasqueron Datasources components.

Dependencies

~8–18MB
~234K SLoC