Source: split response_to_channel into more futures.
This commit is contained in:
parent
46b6c0d27e
commit
1606ceaadb
@ -7,8 +7,8 @@ use hyper::client::HttpConnector;
|
|||||||
use hyper::header::{ETag, EntityTag, HttpDate, IfModifiedSince, IfNoneMatch, LastModified};
|
use hyper::header::{ETag, EntityTag, HttpDate, IfModifiedSince, IfNoneMatch, LastModified};
|
||||||
use hyper_tls::HttpsConnector;
|
use hyper_tls::HttpsConnector;
|
||||||
|
|
||||||
|
use futures::future::ok;
|
||||||
use futures::prelude::*;
|
use futures::prelude::*;
|
||||||
// use futures::future::{ok, result};
|
|
||||||
|
|
||||||
use database::connection;
|
use database::connection;
|
||||||
use errors::*;
|
use errors::*;
|
||||||
@ -165,11 +165,9 @@ fn response_to_channel(res: Response) -> Box<Future<Item = Channel, Error = Erro
|
|||||||
.concat2()
|
.concat2()
|
||||||
.map(|x| x.into_iter())
|
.map(|x| x.into_iter())
|
||||||
.map_err(From::from)
|
.map_err(From::from)
|
||||||
.and_then(|iter| {
|
.and_then(|iter| ok(iter.collect::<Vec<u8>>()))
|
||||||
let utf_8_bytes = iter.collect::<Vec<u8>>();
|
.and_then(|utf_8_bytes| ok(String::from_utf8_lossy(&utf_8_bytes).into_owned()))
|
||||||
let buf = String::from_utf8_lossy(&utf_8_bytes).into_owned();
|
.and_then(|buf| Channel::from_str(&buf).map_err(From::from));
|
||||||
Channel::from_str(&buf).map_err(From::from)
|
|
||||||
});
|
|
||||||
|
|
||||||
Box::new(chan)
|
Box::new(chan)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user