pub trait Header {
// Required method
fn headers(&mut self, headers: BTreeMap<Box<str>, Box<str>>);
}
#[tokio::main]
async fn main() {
use std::collections::BTreeMap;
use surf_header::Header;
use surf_header::parse_to_surf_header;
let h = r##"
GET / HTTP/1.1
Host: crates.io
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.5249.119 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: https://crates.io/
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9
Connection: close
"##;
let info = parse_to_surf_header(h).unwrap();
let mut req = surf::get(info.url).build();
req.headers(info.headers);
let client = surf::Client::new();
let mut res = client.send(req).await.unwrap();
println!("{:?}",res.body_string().await.unwrap());
}