@@ -40,7 +40,7 @@ fn main() {
|
||||
println!("Response: {}", res.status());
|
||||
println!("Headers: {:#?}", res.headers());
|
||||
|
||||
res.into_body().into_stream().for_each(|chunk| {
|
||||
res.into_body().for_each(|chunk| {
|
||||
io::stdout().write_all(&chunk)
|
||||
.map_err(|e| panic!("example expects stdout is open, error={}", e))
|
||||
})
|
||||
|
||||
@@ -32,7 +32,7 @@ impl Service for ParamExample {
|
||||
Box::new(futures::future::ok(Response::new(INDEX.into())))
|
||||
},
|
||||
(&Method::POST, "/post") => {
|
||||
Box::new(req.into_parts().1.into_stream().concat2().map(|b| {
|
||||
Box::new(req.into_body().concat2().map(|b| {
|
||||
// Parse the request body. form_urlencoded::parse
|
||||
// always succeeds, but in general parsing may
|
||||
// fail (for example, an invalid post of json), so
|
||||
|
||||
@@ -44,7 +44,7 @@ impl Service for ResponseExamples {
|
||||
let web_res_future = client.request(req);
|
||||
|
||||
Box::new(web_res_future.map(|web_res| {
|
||||
let body = Body::wrap_stream(web_res.into_body().into_stream().map(|b| {
|
||||
let body = Body::wrap_stream(web_res.into_body().map(|b| {
|
||||
Chunk::from(format!("before: '{:?}'<br>after: '{:?}'",
|
||||
std::str::from_utf8(LOWERCASE).unwrap(),
|
||||
std::str::from_utf8(&b).unwrap()))
|
||||
@@ -54,7 +54,7 @@ impl Service for ResponseExamples {
|
||||
},
|
||||
(&Method::POST, "/web_api") => {
|
||||
// A web api to run against. Simple upcasing of the body.
|
||||
let body = Body::wrap_stream(req.into_body().into_stream().map(|chunk| {
|
||||
let body = Body::wrap_stream(req.into_body().map(|chunk| {
|
||||
let upper = chunk.iter().map(|byte| byte.to_ascii_uppercase())
|
||||
.collect::<Vec<u8>>();
|
||||
Chunk::from(upper)
|
||||
|
||||
Reference in New Issue
Block a user