Skip to content

Commit fe36283

Browse files
finish native-client impl
1 parent 9c25dfd commit fe36283

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ default = ["h1_client"]
2020
docs = ["h1_client"]
2121
h1_client = ["async-h1", "async-std", "async-native-tls"]
2222
native_client = ["curl_client", "wasm_client"]
23-
curl_client = ["isahc"]
23+
curl_client = ["isahc", "async-std"]
2424
wasm_client = ["js-sys", "web-sys", "wasm-bindgen", "wasm-bindgen-futures"]
2525

2626
[dependencies]
@@ -30,12 +30,12 @@ log = "0.4.7"
3030

3131
# h1-client
3232
async-h1 = { version = "1.0.0", optional = true }
33-
async-std = { version = "1.4.0", optional = true }
33+
async-std = { version = "1.4.0", default-features = false, optional = true }
3434
async-native-tls = { version = "0.3.1", optional = true }
3535

3636
# isahc-client
3737
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
38-
isahc = { version = "0.8", git = "https://github.com/sagebind/isahc", optional = true, default-features = false, features = ["http2"] }
38+
isahc = { version = "0.9", optional = true, default-features = false, features = ["http2"] }
3939

4040
# wasm-client
4141
[target.'cfg(target_arch = "wasm32")'.dependencies]

src/isahc.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
use super::{Body, HttpClient, Request, Response};
44

5+
use async_std::io::BufReader;
56
use futures::future::BoxFuture;
67
use isahc::http;
78

@@ -59,12 +60,10 @@ impl HttpClient for IsahcClient {
5960

6061
let (parts, body) = res.into_parts();
6162

62-
// FIXME: isahc::Body is !Sync, making it impossible to pass to http::Response
63-
unimplemented!();
64-
65-
// let body = Body::from_reader(body, body.len().map(|len| len as usize));
66-
// let res = http::Response::from_parts(parts, body);
67-
// Ok(res.into())
63+
let len = body.len().map(|len| len as usize);
64+
let body = Body::from_reader(BufReader::new(body), len);
65+
let res = http::Response::from_parts(parts, body);
66+
Ok(res.into())
6867
})
6968
}
7069
}

0 commit comments

Comments
 (0)