Skip to content

Commit 3a56e67

Browse files
taiki-eFishrock123
authored andcommitted
Fix h1-client and default-client feature
This also adds a CI task to check all feature combinations work properly.
1 parent fc75a59 commit 3a56e67

File tree

4 files changed

+63
-9
lines changed

4 files changed

+63
-9
lines changed

.github/workflows/ci.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,17 @@ jobs:
8787

8888
- name: docs
8989
run: cargo doc --no-deps
90+
91+
check_features:
92+
name: Check feature combinations
93+
runs-on: ubuntu-latest
94+
steps:
95+
- uses: actions/checkout@master
96+
97+
- name: Install cargo-hack
98+
run: cargo install cargo-hack
99+
100+
- name: Check all feature combinations works properly
101+
# * `--feature-powerset` - run for the feature powerset of the package
102+
# * `--no-dev-deps` - build without dev-dependencies to avoid https://github.com/rust-lang/cargo/issues/4866
103+
run: cargo hack check --feature-powerset --no-dev-deps

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description = "Surf the web - HTTP client framework"
88
keywords = ["http", "client", "framework", "request", "async"]
99
categories = ["web-programming", "web-programming::http-client"]
1010
authors = [
11-
"Yoshua Wuyts <[email protected]>",
11+
"Yoshua Wuyts <[email protected]>",
1212
"dignifiedquire <[email protected]>",
1313
"Renée Kooi <[email protected]>",
1414
"Jeremiah Senkpiel <[email protected]>"
@@ -21,7 +21,7 @@ edition = "2018"
2121
# `.github/workflows/ci.yaml` are updated accordingly
2222
default = ["curl-client", "middleware-logger", "encoding"]
2323
curl-client = ["http-client/curl_client", "once_cell", "default-client"]
24-
h1-client = ["http-client/h1_client", "default-client"]
24+
h1-client = ["http-client/h1_client", "http-client/native-tls", "default-client"]
2525
hyper-client = ["http-client/hyper_client", "once_cell", "default-client", "async-std/tokio02"]
2626
wasm-client = ["http-client/wasm_client", "default-client"]
2727
default-client = []
@@ -35,7 +35,7 @@ log = { version = "0.4.7", features = ["kv_unstable"] }
3535
mime_guess = "2.0.3"
3636
serde = "1.0.97"
3737
serde_json = "1.0.40"
38-
http-client = { version = "6.1.0", default-features = false }
38+
http-client = { version = "6.3.0", default-features = false }
3939
http-types = "2.5.0"
4040
async-std = { version = "1.6.0", default-features = false, features = ["std"] }
4141
async-trait = "0.1.36"

src/client.rs

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use cfg_if::cfg_if;
1010
cfg_if! {
1111
if #[cfg(feature = "curl-client")] {
1212
use http_client::isahc::IsahcClient as DefaultClient;
13-
} else if #[cfg(feature = "wasm-client")] {
13+
} else if #[cfg(all(feature = "wasm-client", target_arch = "wasm32"))] {
1414
use http_client::wasm::WasmClient as DefaultClient;
1515
} else if #[cfg(feature = "h1-client")] {
1616
use http_client::h1::H1Client as DefaultClient;
@@ -76,7 +76,15 @@ impl fmt::Debug for Client {
7676
}
7777
}
7878

79-
#[cfg(feature = "default-client")]
79+
#[cfg(all(
80+
feature = "default-client",
81+
any(
82+
feature = "curl-client",
83+
all(feature = "wasm-client", target_arch = "wasm32"),
84+
feature = "h1-client",
85+
feature = "hyper-client"
86+
)
87+
))]
8088
impl Default for Client {
8189
fn default() -> Self {
8290
Self::new()
@@ -97,14 +105,30 @@ impl Client {
97105
/// let res = client.send(req).await?;
98106
/// # Ok(()) }
99107
/// ```
100-
#[cfg(feature = "default-client")]
108+
#[cfg(all(
109+
feature = "default-client",
110+
any(
111+
feature = "curl-client",
112+
all(feature = "wasm-client", target_arch = "wasm32"),
113+
feature = "h1-client",
114+
feature = "hyper-client"
115+
)
116+
))]
101117
pub fn new() -> Self {
102118
Self::with_http_client(DefaultClient::new())
103119
}
104120

105121
pub(crate) fn new_shared_or_panic() -> Self {
106122
cfg_if! {
107-
if #[cfg(feature = "default-client")] {
123+
if #[cfg(all(
124+
feature = "default-client",
125+
any(
126+
feature = "curl-client",
127+
all(feature = "wasm-client", target_arch = "wasm32"),
128+
feature = "h1-client",
129+
feature = "hyper-client"
130+
)
131+
))] {
108132
Self::new_shared()
109133
} else {
110134
panic!("default client not configured")
@@ -140,7 +164,15 @@ impl Client {
140164
client
141165
}
142166

143-
#[cfg(feature = "default-client")]
167+
#[cfg(all(
168+
feature = "default-client",
169+
any(
170+
feature = "curl-client",
171+
all(feature = "wasm-client", target_arch = "wasm32"),
172+
feature = "h1-client",
173+
feature = "hyper-client"
174+
)
175+
))]
144176
pub(crate) fn new_shared() -> Self {
145177
cfg_if! {
146178
if #[cfg(any(feature = "curl-client", feature = "hyper-client"))] {

src/lib.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,15 @@ pub use request_builder::RequestBuilder;
9696
pub use response::{DecodeError, Response};
9797

9898
cfg_if::cfg_if! {
99-
if #[cfg(feature = "default-client")] {
99+
if #[cfg(all(
100+
feature = "default-client",
101+
any(
102+
feature = "curl-client",
103+
all(feature = "wasm-client", target_arch = "wasm32"),
104+
feature = "h1-client",
105+
feature = "hyper-client"
106+
)
107+
))] {
100108
mod one_off;
101109
pub use one_off::{connect, delete, get, head, options, patch, post, put, trace};
102110

0 commit comments

Comments
 (0)