Skip to content

Instantly share code, notes, and snippets.

@mfpiccolo
Created July 8, 2015 05:24
Show Gist options
  • Save mfpiccolo/d5008b007693723c8469 to your computer and use it in GitHub Desktop.
Save mfpiccolo/d5008b007693723c8469 to your computer and use it in GitHub Desktop.
#![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