Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is Reqwest higher level than Hyper?

According to the docs on Hyper.rs,

If you are looking for a convenient HTTP client, then you may wish to consider reqwest. If you are looking for a convenient HTTP server, then you may wish to consider warp. Both are built on top of this library.

Looking at the api, it seems Hyper.rs is already pretty high level. It supports proxies, tls, and cookies... Why is Reqwest more high level?

like image 990
NO WAR WITH RUSSIA Avatar asked Dec 03 '25 22:12

NO WAR WITH RUSSIA


1 Answers

Hyper requires you to take care of lower level details, like parsing the URI (example from the documentation):

let client = Client::new();
let uri = "http://httpbin.org/ip".parse()?;
let mut resp = client.get(uri).await?;

while let Some(chunk) = resp.body_mut().data().await {
    stdout().write_all(&chunk?).await?;
}

while reqwest handle this for you (from docs.rs) :

let body = reqwest::get("https://www.rust-lang.org")
    .await?
    .text()
    .await?;
like image 124
Clément Joly Avatar answered Dec 06 '25 14:12

Clément Joly