diff --git a/src/response.rs b/src/response.rs index d84de5a..f2defe9 100644 --- a/src/response.rs +++ b/src/response.rs @@ -176,12 +176,12 @@ impl Response { /// # Ok(()) /// # } /// ``` - pub fn text(&mut self) -> io::Result { + pub fn text(&mut self) -> ::Result { let len = self.headers().get::<::header::ContentLength>() .map(|ct_len| **ct_len) .unwrap_or(0); let mut content = String::with_capacity(len as usize); - self.read_to_string(&mut content)?; + self.read_to_string(&mut content).map_err(::error::from)?; Ok(content) } @@ -205,10 +205,10 @@ impl Response { /// # } /// ``` #[inline] - pub fn copy_to(&mut self, w: &mut W) -> io::Result + pub fn copy_to(&mut self, w: &mut W) -> ::Result where W: io::Write { - io::copy(self, w) + io::copy(self, w).map_err(::error::from) } /// Turn a response into an error if the server returned an error.