mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
net.http: add graceful shutdown .stop() method to the http.Server struct (#11233)
This commit is contained in:
16
vlib/net/http/server_test.v
Normal file
16
vlib/net/http/server_test.v
Normal file
@@ -0,0 +1,16 @@
|
||||
module http
|
||||
|
||||
import time
|
||||
|
||||
fn test_server_stop() ? {
|
||||
server := &Server{
|
||||
accept_timeout: 1 * time.second
|
||||
}
|
||||
t := go server.listen_and_serve()
|
||||
time.sleep(250 * time.millisecond)
|
||||
mut watch := time.new_stopwatch()
|
||||
server.stop()
|
||||
assert watch.elapsed() < 100 * time.millisecond
|
||||
t.wait() ?
|
||||
assert watch.elapsed() < 999 * time.millisecond
|
||||
}
|
||||
Reference in New Issue
Block a user