1
0
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:
Miccah
2021-08-19 03:19:49 -05:00
committed by GitHub
parent 7bffabbce2
commit 6991a3c8d5
3 changed files with 41 additions and 7 deletions

View 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
}