Created
July 8, 2015 05:24
-
-
Save mfpiccolo/d5008b007693723c8469 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(slice_chars)] | |
extern crate hyper; | |
use hyper::Client; | |
use hyper::header::Connection; | |
use std::io::Read; | |
fn get_body(url: &str) -> String { | |
let client = Client::new(); | |
let temp_resp = client.get(url).header(Connection::close()).send(); | |
let mut resp = temp_resp.unwrap(); | |
let mut body = String::new(); | |
resp.read_to_string(&mut body).unwrap(); | |
body | |
} | |
#[test] | |
fn it_works() { | |
assert_eq!( | |
get_body(&"http://www.rust-lang.org".to_string()).slice_chars(73, 105), | |
"<title>The Rust Programming Lang" | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment