Starting with hyper 0.12, the following works on the condition that the web page is valid UTF-8:
extern crate hyper; extern crate hyper_tls; use hyper::Client; use hyper::rt::{self, Future, Stream}; use hyper_tls::HttpsConnector; fn main() { rt::run(rt::lazy(|| { let https = HttpsConnector::new(4).unwrap(); let client = Client::builder().build::<_, hyper::Body>(https); client.get("https://www.reddit.com/r/programming/.rss".parse().unwrap()) .and_then(|res| { println!("status {}", res.status()); res.into_body().concat2() }).map(|body| { println!("Body {}", String::from_utf8(body.to_vec()).unwrap()); }) .map_err(|err| { println!("error {}", err) }) })); }
source share