Skip to content

Commit 3953af3

Browse files
committed
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.
1 parent 999c30c commit 3953af3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/response.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,11 @@ impl Response {
218218
// })
219219
// }
220220

221+
/// Take the request body, replacing it with an empty body.
222+
pub fn take_body(&mut self) -> Body {
223+
self.res.take_body()
224+
}
225+
221226
/// Add cookie to the cookie jar.
222227
pub fn set_cookie(&mut self, cookie: Cookie<'static>) {
223228
self.cookie_events.push(CookieEvent::Added(cookie));

0 commit comments

Comments
 (0)