diff --git a/src/body.rs b/src/body.rs index 1f218c4ba..d72f6c378 100644 --- a/src/body.rs +++ b/src/body.rs @@ -59,6 +59,12 @@ impl ResponseBody { } } +impl ResponseBody { + pub fn take_body(&mut self) -> ResponseBody { + std::mem::replace(self, ResponseBody::Other(Body::None)) + } +} + impl ResponseBody { pub fn as_ref(&self) -> Option<&B> { if let ResponseBody::Body(ref b) = self { diff --git a/src/response.rs b/src/response.rs index 277890e40..4e1fe2142 100644 --- a/src/response.rs +++ b/src/response.rs @@ -254,6 +254,11 @@ impl Response { error: self.error, } } + + /// Extract response body + pub fn take_body(&mut self) -> ResponseBody { + self.body.take_body() + } } impl fmt::Debug for Response {