File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ edition = "2018"
15
15
httparse = " 1.3.3"
16
16
http = " 0.1.17"
17
17
futures-io = " 0.3.0"
18
- async-std = " 0.99.12"
18
+ async-std = { version = " 0.99.12" , features = [ " unstable " ] }
19
19
futures-core-preview = " 0.3.0-alpha.18"
20
20
21
21
[dev-dependencies ]
Original file line number Diff line number Diff line change 1
1
//! Process HTTP connections on the server.
2
2
3
- use async_std:: future:: { timeout , Future } ;
3
+ use async_std:: future:: Future ;
4
4
use async_std:: io:: { self , BufReader } ;
5
5
use async_std:: io:: { Read , Write } ;
6
6
use async_std:: prelude:: * ;
7
- use async_std:: task:: { Context , Poll } ;
7
+ use async_std:: task:: { sleep , Context , Poll } ;
8
8
use futures_core:: ready;
9
9
use http:: { Request , Response , Version } ;
10
10
@@ -34,14 +34,20 @@ where
34
34
let reader = res. body . into_reader ( ) . unwrap ( ) ;
35
35
let decoder = Decoder :: new ( reader) ;
36
36
match decoder. decode ( ) . await ? {
37
- // TODO: no unwrap
38
37
Some ( r) => req = r,
39
38
None => break ,
40
39
}
41
40
}
42
41
43
42
Ok :: < ( ) , Exception > ( ( ) )
44
43
} ;
44
+
45
+ let timer = async {
46
+ sleep ( std:: time:: Duration :: from_secs ( 5 ) ) . await ;
47
+ Ok :: < ( ) , Exception > ( ( ) )
48
+ } ;
49
+
50
+ handle. race ( timer) . await ?;
45
51
}
46
52
47
53
Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments