summaryrefslogtreecommitdiffstats
path: root/ipfs-api
diff options
context:
space:
mode:
authorJulius Michaelis <gitter@liftm.de>2021-01-11 23:09:28 +0900
committerJulius Michaelis <gitter@liftm.de>2021-01-17 16:46:36 +0900
commitc465720a494312aea93aa87e16ff6baf25ef2e11 (patch)
treef3c437c3d6ace34201ea4c6827941df56dba540b /ipfs-api
parent57f27461943670f3d024e0e4ece9fb2a15035344 (diff)
allow hyper-rustls or no tls as alternatives for hyper-tls
(Another attempt at @akru's #39.)
Diffstat (limited to 'ipfs-api')
-rw-r--r--ipfs-api/Cargo.toml1
-rw-r--r--ipfs-api/src/client/internal.rs5
-rw-r--r--ipfs-api/src/lib.rs15
3 files changed, 16 insertions, 5 deletions
diff --git a/ipfs-api/Cargo.toml b/ipfs-api/Cargo.toml
index 88ed983..2fba349 100644
--- a/ipfs-api/Cargo.toml
+++ b/ipfs-api/Cargo.toml
@@ -30,6 +30,7 @@ futures = "0.3"
http = "0.2"
hyper = { version = "0.13", optional = true }
hyper-tls = { version = "0.4", optional = true }
+hyper-rustls = { version = "0.20", optional = true }
hyper-multipart-rfc7578 = { version = "0.4.0-rc", optional = true }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
diff --git a/ipfs-api/src/client/internal.rs b/ipfs-api/src/client/internal.rs
index 2b1f62f..c94ecb7 100644
--- a/ipfs-api/src/client/internal.rs
+++ b/ipfs-api/src/client/internal.rs
@@ -26,7 +26,8 @@ use hyper::{body, client::Builder};
#[cfg(feature = "hyper")]
use hyper_multipart::client::multipart;
#[cfg(feature = "hyper")]
-use hyper_tls::HttpsConnector;
+use crate::HyperConnector;
+
use serde::{Deserialize, Serialize};
use serde_json;
#[cfg(feature = "actix")]
@@ -64,7 +65,7 @@ impl TryFromUri for IpfsClient {
{
Builder::default()
.pool_max_idle_per_host(0)
- .build(HttpsConnector::new())
+ .build(HyperConnector::new())
}
#[cfg(feature = "actix")]
{
diff --git a/ipfs-api/src/lib.rs b/ipfs-api/src/lib.rs
index d31b4e7..62a96c8 100644
--- a/ipfs-api/src/lib.rs
+++ b/ipfs-api/src/lib.rs
@@ -171,8 +171,17 @@ pub mod response;
use actix_http::{encoding, Payload, PayloadStream};
#[cfg(feature = "hyper")]
use hyper::{self, client::HttpConnector};
-#[cfg(feature = "hyper")]
-use hyper_tls::HttpsConnector;
+#[cfg(all(feature = "hyper-rustls", feature = "hyper-tls"))]
+compile_error!("Pick only one of the features: hyper-tls, hyper-rustls");
+#[cfg(all(feature = "hyper-tls", not(feature = "hyper-rustls")))]
+type HyperConnector = hyper_tls::HttpsConnector<HttpConnector>;
+#[cfg(all(feature = "hyper-rustls", not(feature = "hyper-tls")))]
+type HyperConnector = hyper_rustls::HttpsConnector<HttpConnector>;
+#[cfg(all(feature = "hyper", any(
+ not(any(feature = "hyper-tls", feature = "hyper-rustls")),
+ all(feature = "hyper-rustls", feature = "hyper-tls"),
+)))]
+type HyperConnector = HttpConnector;
#[cfg(feature = "actix")]
pub(crate) type Request = awc::SendClientRequest;
@@ -187,4 +196,4 @@ pub(crate) type Response = http::Response<hyper::Body>;
#[cfg(feature = "actix")]
pub(crate) type Client = awc::Client;
#[cfg(feature = "hyper")]
-pub(crate) type Client = hyper::client::Client<HttpsConnector<HttpConnector>, hyper::Body>;
+pub(crate) type Client = hyper::client::Client<HyperConnector, hyper::Body>;