feat(server): change Incoming to iterator over Connections

A connection is returned from Incoming.next(), and can be passed to a
separate thread before any parsing happens. Call conn.open() to get a
Result<(Request, Response)>.

BREAKING CHANGE
This commit is contained in:
Sean McArthur
2014-11-10 13:55:11 -08:00
parent 0500b5f17f
commit 3c10a8a191
6 changed files with 45 additions and 34 deletions

View File

@@ -8,8 +8,9 @@ static PHRASE: &'static [u8] = b"Hello World!";
fn hyper_handle(mut incoming: hyper::server::Incoming) {
let mut pool = TaskPool::new(100, || { proc(_) { } });
for (_, mut res) in incoming {
for conn in incoming {
pool.execute(proc(_) {
let (_, res) = conn.open().unwrap();
let mut res = res.start().unwrap();
res.write(PHRASE).unwrap();
res.end().unwrap();