diff --git a/tests/rdf_test_cases.rs b/tests/rdf_test_cases.rs index 3449a384..9da67ae4 100644 --- a/tests/rdf_test_cases.rs +++ b/tests/rdf_test_cases.rs @@ -5,6 +5,7 @@ extern crate rudf; extern crate url; use reqwest::Client; +use reqwest::Response; use rudf::model::data::*; use rudf::model::vocab::rdf; use rudf::model::vocab::rdfs; @@ -14,7 +15,7 @@ use rudf::rio::ntriples::read_ntriples; use rudf::rio::turtle::read_turtle; use rudf::store::isomorphism::GraphIsomorphism; use rudf::store::memory::MemoryGraph; -use std::iter::FromIterator; +use std::error::Error; use std::str::FromStr; use url::Url; @@ -31,17 +32,22 @@ impl Default for RDFClient { } impl RDFClient { - fn load_turtle(&self, uri: Url) -> RioResult { - match self.client.get(uri.clone()).send() { - Ok(response) => Ok(MemoryGraph::from_iter(read_turtle(response, Some(uri))?)), - Err(error) => Err(RioError::new(error)), - } + fn load_turtle(&self, url: Url) -> RioResult { + Ok(read_turtle(self.get(&url)?, Some(url))?.collect()) + } + + fn load_ntriples(&self, url: Url) -> RioResult { + read_ntriples(self.get(&url)?).collect() } - fn load_ntriples(&self, uri: Url) -> RioResult { - match self.client.get(uri).send() { - Ok(response) => read_ntriples(response).collect(), - Err(error) => Err(RioError::new(error)), + fn get(&self, url: &Url) -> RioResult { + match self.client.get(url.clone()).send() { + Ok(response) => Ok(response), + Err(error) => if error.description() == "message is incomplete" { + self.get(url) + } else { + Err(RioError::new(error)) + }, } } }