Page MenuHomeDevCentral

D3455.id8909.diff
No OneTemporary

D3455.id8909.diff

diff --git a/ds-http-client/Cargo.toml b/ds-http-client/Cargo.toml
--- a/ds-http-client/Cargo.toml
+++ b/ds-http-client/Cargo.toml
@@ -2,6 +2,11 @@
name = "ds-http-client"
version = "0.1.0"
edition = "2021"
+description = "HTTP client to download files or query API with User-Agent set"
+authors = [
+ "Sébastien Santoro <dereckson@espace-win.org>"
+]
+license = "BSD-2-Clause"
[dependencies]
lazy_static = "~1.5.0"
diff --git a/ds-http-client/README.md b/ds-http-client/README.md
new file mode 100644
--- /dev/null
+++ b/ds-http-client/README.md
@@ -0,0 +1,34 @@
+# 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);
+ }
+ ```

File Metadata

Mime Type
text/plain
Expires
Sun, Sep 29, 17:09 (2 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2164418
Default Alt Text
D3455.id8909.diff (1 KB)

Event Timeline