在Rust中使用reqwest抓取响应标头值 异步/等待阻止API

问题描述

过去几天,我主要在尝试reqwest模块,以了解我可以完成的工作,但是我遇到了一个无法解决的问题。我试图在执行发布请求后检索响应标头值。我尝试过的代码是

extern crate reqwest;

fn main() {
   let client = reqwest::Client::new();
   let res = client
    .post("https://google.com")
    .header("testerheader","test")
    .send();
   println!("Headers:\n{:#?}",res.headers().get("content-length").unwrap());
}

此代码似乎返回此错误

error[E0599]: no method named `headers` found for opaque type `impl std::future::Future` in the current scope

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)