feat(body): implement HttpBody for Request and Response
When the body type of a `Request` or `Response` implements `HttpBody`, the `Request` or `Response` itself now implements `HttpBody`. This allows writing things like `hyper::body::aggregate(req)` instead of `hyper::body::aggregate(req.into_body())`. Closes #2067
This commit is contained in:
@@ -40,7 +40,7 @@ async fn client_request_response(client: &Client<HttpConnector>) -> Result<Respo
|
||||
|
||||
async fn api_post_response(req: Request<Body>) -> Result<Response<Body>> {
|
||||
// Aggregate the body...
|
||||
let whole_body = hyper::body::aggregate(req.into_body()).await?;
|
||||
let whole_body = hyper::body::aggregate(req).await?;
|
||||
// Decode as JSON...
|
||||
let mut data: serde_json::Value = serde_json::from_reader(whole_body.reader())?;
|
||||
// Change the JSON...
|
||||
|
||||
Reference in New Issue
Block a user