From 3953af3f64c1d0e92cf0e8f9daa2ef7d37c4ecda Mon Sep 17 00:00:00 2001 From: Jeremiah Senkpiel Date: Wed, 13 May 2020 15:23:14 -0700 Subject: [PATCH] Response: add `take_body()` as a way to get the body from a Response This is useful for middleware that may want to post-process body data, such as a compression middleware. --- src/response.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/response.rs b/src/response.rs index 458c69d00..cb295f663 100644 --- a/src/response.rs +++ b/src/response.rs @@ -218,6 +218,11 @@ impl Response { // }) // } + /// Take the request body, replacing it with an empty body. + pub fn take_body(&mut self) -> Body { + self.res.take_body() + } + /// Add cookie to the cookie jar. pub fn set_cookie(&mut self, cookie: Cookie<'static>) { self.cookie_events.push(CookieEvent::Added(cookie));