Skip to content

Commit

Permalink
Added a download method
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Dec 3, 2014
1 parent 59d2ccd commit b67bde2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 16 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,29 @@ use std::str;


fn main() {

let turtle_file = download("http://localhost:8983/fedora/rest");
turtle::parse(turtle_file.as_slice());

/*println!("code={}; headers={}; body={}",*/
/* resp.get_code(), resp.get_headers(), body_string);*/
}

fn download(uri: &str) -> String {
let resp = http::handle()
.get("http://localhost:8983/fedora/rest")
.get(uri)
.exec().unwrap();

let body_string = match str::from_utf8(resp.get_body()) {
Some(e) => e,
None => panic!("Invalid UTF-8 sequence"),
if resp.get_code() != 200 {
panic!("Server didn't give 200 response");
};

turtle::parse(body_string);

println!("code={}; headers={}; body={}",
resp.get_code(), resp.get_headers(), body_string);
match str::from_utf8(resp.get_body()) {
Some(e) => e.to_string(),
None => panic!("Invalid UTF-8 sequence"),
}
}


mod rdf {
pub struct URI(pub String);

Expand Down

0 comments on commit b67bde2

Please sign in to comment.