Repository: seanmonstar/reqwest (language: rust)

Issue:
Response.into_body would be nice to have
... instead of needing to `mem::replace(response.body_mut(), Decoder::empty)` like the current code requires.

Otherwise, it would be nice if `Decoder` impled `Default::default() -> Decoder::empty()` to save on imported types.


Discussion / hints:
Both additions sound good to me!

Fix patch:
diff --git a/src/async_impl/response.rs b/src/async_impl/response.rs
index 9572868b8..0d14b5711 100644
--- a/src/async_impl/response.rs
+++ b/src/async_impl/response.rs
@@ -51,6 +51,11 @@ impl Response {
         &mut self.headers
     }
 
+    /// Consumes the response, returning the body
+    pub fn into_body(self) -> Decoder {
+        self.body
+    }
+
     /// Get a reference to the response body.
     #[inline]
     pub fn body(&self) -> &Decoder {


Test patch:
diff --git a/tests/async.rs b/tests/async.rs
index 9697d3d97..937c32209 100644
--- a/tests/async.rs
+++ b/tests/async.rs
@@ -8,8 +8,7 @@ extern crate libflate;
 #[macro_use]
 mod support;
 
-use std::mem;
-use reqwest::unstable::async::{Client, Decoder};
+use reqwest::unstable::async::Client;
 use futures::{Future, Stream};
 use tokio_core::reactor::Core;
 use std::io::Write;
@@ -64,8 +63,8 @@ fn test_gzip(response_size: usize, chunk_size: usize) {
 
     let res_future = client.get(&format!("http://{}/gzip", server.addr()))
         .send()
-        .and_then(|mut res| {
-            let body = mem::replace(res.body_mut(), Decoder::empty());
+        .and_then(|res| {
+            let body = res.into_body();
             body.concat2()
         })
         .and_then(|buf| {