From 6420a2fe1f14b8fc6de12f9f3b19679dd11340e2 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Wed, 10 Apr 2019 20:57:18 -0700 Subject: [PATCH] update client example --- examples/client.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/examples/client.rs b/examples/client.rs index c4df6f7d6..8a75fd306 100644 --- a/examples/client.rs +++ b/examples/client.rs @@ -1,7 +1,6 @@ use actix_http::Error; use actix_rt::System; -use bytes::BytesMut; -use futures::{future::lazy, Future, Stream}; +use futures::{future::lazy, Future}; fn main() -> Result<(), Error> { std::env::set_var("RUST_LOG", "actix_http=trace"); @@ -13,17 +12,14 @@ fn main() -> Result<(), Error> { .header("User-Agent", "Actix-web") .send() // <- Send http request .from_err() - .and_then(|response| { + .and_then(|mut response| { // <- server http response println!("Response: {:?}", response); // read response body response + .body() .from_err() - .fold(BytesMut::new(), move |mut acc, chunk| { - acc.extend_from_slice(&chunk); - Ok::<_, Error>(acc) - }) .map(|body| println!("Downloaded: {:?} bytes", body.len())) }) }))