How to add hyper header information?


Hi all. I tried not to get body without header, I can’t get, and other sites can, I now want to add header, but did not succeed, please help to see, thank you! How to change it?

The 18 line error info: the trait hyper::header::Header is not implemented for &std::collections::HashMap<&str, &str>


Use the types in the hyper::header module to control headers. For example:

    let res = client.get(url)
        .header(AcceptEncoding(vec![qitem(Encoding::Gzip), qitem(Encoding::Deflate)]))


mbrubeck: Thanks a lot!. Second questions, the page is charset=gb2312, println! can’t print, how to convert to utf8? What modules or functions can be work? thank you!!


I would recommend the encoding crate

I doesn’t support gb2312, but it supports GBK and GB 18030, which I understand are extensions of gb2312, so it should probably work.


krdln: Okay. thx a lot! This library should be able to solve my problem.