File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -25,20 +25,19 @@ where
25
25
Fut : Future < Output = Result < Response < Body < O > > , Exception > > ,
26
26
O : Read + Unpin + Send ,
27
27
{
28
+ // TODO: make configurable
29
+ let timeout_duration = Duration :: from_secs ( 10 ) ;
30
+ const MAX_REQUESTS : usize = 200 ;
31
+
28
32
let req = decode ( reader) . await ?;
33
+ let mut num_requests = 0 ;
29
34
if let Some ( mut req) = req {
30
- let headers = req. headers ( ) ;
31
- let timeout_duration = match ( headers. get ( "Connection" ) , headers. get ( "Keep-Alive" ) ) {
32
- ( Some ( connection) , Some ( _v) )
33
- if connection == http:: header:: HeaderValue :: from_static ( "Keep-Alive" ) =>
34
- {
35
- // TODO: parse timeout
36
- Duration :: from_secs ( 10 )
35
+ loop {
36
+ num_requests += 1 ;
37
+ if num_requests > MAX_REQUESTS {
38
+ return Ok ( ( ) ) ;
37
39
}
38
- _ => Duration :: from_secs ( 10 ) ,
39
- } ;
40
40
41
- loop {
42
41
// TODO: what to do when the callback returns Err
43
42
let mut res = encode ( callback ( & mut req) . await ?) . await ?;
44
43
io:: copy ( & mut res, writer) . await ?;
You can’t perform that action at this time.
0 commit comments