Skip to content

Commit 2e269cc

Browse files
committed
Further step to working keep-alive
1 parent c1e896f commit 2e269cc

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ edition = "2018"
1515
httparse = "1.3.3"
1616
http = "0.1.17"
1717
futures-io = "0.3.0"
18-
async-std = "0.99.12"
18+
async-std = { version = "0.99.12", features = ["unstable"] }
1919
futures-core-preview = "0.3.0-alpha.18"
2020

2121
[dev-dependencies]

src/server.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
//! Process HTTP connections on the server.
22
3-
use async_std::future::{timeout, Future};
3+
use async_std::future::Future;
44
use async_std::io::{self, BufReader};
55
use async_std::io::{Read, Write};
66
use async_std::prelude::*;
7-
use async_std::task::{Context, Poll};
7+
use async_std::task::{sleep, Context, Poll};
88
use futures_core::ready;
99
use http::{Request, Response, Version};
1010

@@ -34,14 +34,20 @@ where
3434
let reader = res.body.into_reader().unwrap();
3535
let decoder = Decoder::new(reader);
3636
match decoder.decode().await? {
37-
// TODO: no unwrap
3837
Some(r) => req = r,
3938
None => break,
4039
}
4140
}
4241

4342
Ok::<(), Exception>(())
4443
};
44+
45+
let timer = async {
46+
sleep(std::time::Duration::from_secs(5)).await;
47+
Ok::<(), Exception>(())
48+
};
49+
50+
handle.race(timer).await?;
4551
}
4652

4753
Ok(())

0 commit comments

Comments
 (0)