diff --git a/basics/http-proxy/src/main.rs b/basics/http-proxy/src/main.rs index 611f5851..fecdf9a8 100644 --- a/basics/http-proxy/src/main.rs +++ b/basics/http-proxy/src/main.rs @@ -7,7 +7,7 @@ use url::Url; async fn forward( req: HttpRequest, - body: web::Bytes, + payload: web::Payload, url: web::Data, client: web::Data, ) -> Result { @@ -26,7 +26,10 @@ async fn forward( forwarded_req }; - let mut res = forwarded_req.send_body(body).await.map_err(Error::from)?; + let res = forwarded_req + .send_stream(payload) + .await + .map_err(Error::from)?; let mut client_resp = HttpResponse::build(res.status()); // Remove `Connection` as per @@ -37,7 +40,7 @@ async fn forward( client_resp.header(header_name.clone(), header_value.clone()); } - Ok(client_resp.body(res.body().await?)) + Ok(client_resp.streaming(res)) } #[actix_web::main]