Restore HTTP client transition, but use reqwest everywhere (#19055)
Release Notes: - N/A
This commit is contained in:
parent
c709b66f35
commit
22ac178f9d
35 changed files with 838 additions and 418 deletions
41
crates/reqwest_client/examples/client.rs
Normal file
41
crates/reqwest_client/examples/client.rs
Normal file
|
@ -0,0 +1,41 @@
|
|||
use std::time::Instant;
|
||||
|
||||
use futures::stream::FuturesUnordered;
|
||||
use futures::AsyncReadExt as _;
|
||||
use http_client::AsyncBody;
|
||||
use http_client::HttpClient;
|
||||
use reqwest_client::ReqwestClient;
|
||||
use smol::stream::StreamExt;
|
||||
|
||||
fn main() {
|
||||
let app = gpui::App::new();
|
||||
app.run(|cx| {
|
||||
cx.spawn(|cx| async move {
|
||||
let client = ReqwestClient::new();
|
||||
let start = Instant::now();
|
||||
let requests = [
|
||||
client.get("https://www.google.com/", AsyncBody::empty(), true),
|
||||
client.get("https://zed.dev/", AsyncBody::empty(), true),
|
||||
client.get("https://docs.rs/", AsyncBody::empty(), true),
|
||||
];
|
||||
let mut requests = requests.into_iter().collect::<FuturesUnordered<_>>();
|
||||
while let Some(response) = requests.next().await {
|
||||
let mut body = String::new();
|
||||
response
|
||||
.unwrap()
|
||||
.into_body()
|
||||
.read_to_string(&mut body)
|
||||
.await
|
||||
.unwrap();
|
||||
println!("{}", &body.len());
|
||||
}
|
||||
println!("{:?}", start.elapsed());
|
||||
|
||||
cx.update(|cx| {
|
||||
cx.quit();
|
||||
})
|
||||
.ok();
|
||||
})
|
||||
.detach();
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue