Hyper需要您处理低级别的细节,例如解析URI(来自文档的示例):
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?;
}
当您使用reqwest时,它会为您处理这个问题(来自docs.rs) :
let body = reqwest::get("https://www.rust-lang.org")
.await?
.text()
.await?;