aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Wortman <me@iximeow.net>2017-07-15 20:45:19 -0700
committerAndy Wortman <me@iximeow.net>2017-07-15 20:45:19 -0700
commitb888282e1dc56cd7a63d88e9426488ab2772c0ef (patch)
tree72b76108179ae47ca7181a309f924fc144b8e48b
parentea47395001100144cda08884c614ddba0e8a034b (diff)
with great healp from rschifflin this is way way way way way cleaner
(i gotta go back and look at futures::stream::iter and into_iter() vs iter()) and try doing this myself again until i can follow the types a lil better
-rw-r--r--main.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/main.rs b/main.rs
index c55eba2..828cc22 100644
--- a/main.rs
+++ b/main.rs
@@ -121,6 +121,7 @@ fn main() {
};
println!("requesting...");
+ /*
let work = client.request(req).and_then(|res| {
res.body().for_each(move |body: hyper::Chunk| {
println!("hmmm");
@@ -128,6 +129,13 @@ fn main() {
Ok(())
})
});
+ */
+
+ let work = client.request(req).and_then(|res| {
+ res.body()
+ .map(|chunk| futures::stream::iter(chunk.into_iter().map(|b| -> Result<u8, hyper::Error> { Ok(b) })))
+ .flatten().for_each(|byte| Ok(print!("{}", byte as char)))
+ });
println!("Before?");
let resp = core.run(work).unwrap();