feat(body): replace Chunk type with Bytes

Closes #1931

BREAKING CHANGE: All usage of `hyper::Chunk` should be replaced with
  `bytes::Bytes` (or `hyper::body::Bytes`).
This commit is contained in:
Sean McArthur
2019-12-05 16:56:35 -08:00
parent c56ccfb033
commit 5a59875742
10 changed files with 59 additions and 245 deletions

View File

@@ -3,7 +3,7 @@
use futures_util::{StreamExt, TryStreamExt};
use hyper::client::HttpConnector;
use hyper::service::{make_service_fn, service_fn};
use hyper::{header, Body, Chunk, Client, Method, Request, Response, Server, StatusCode};
use hyper::{header, Body, Client, Method, Request, Response, Server, StatusCode};
type GenericError = Box<dyn std::error::Error + Send + Sync>;
type Result<T> = std::result::Result<T, GenericError>;
@@ -25,11 +25,11 @@ async fn client_request_response(client: &Client<HttpConnector>) -> Result<Respo
let web_res = client.request(req).await?;
// Compare the JSON we sent (before) with what we received (after):
let body = Body::wrap_stream(web_res.into_body().map_ok(|b| {
Chunk::from(format!(
format!(
"<b>POST request body</b>: {}<br><b>Response</b>: {}",
POST_DATA,
std::str::from_utf8(&b).unwrap()
))
)
}));
Ok(Response::new(body))