aboutsummaryrefslogtreecommitdiff
path: root/src/net/http/export_test.go
diff options
context:
space:
mode:
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>2016-02-29 12:06:57 -0300
committerBrad Fitzpatrick <bradfitz@golang.org>2016-03-07 23:42:19 +0000
commitbd68b8abc2e3ceaa3b9bde98568a4a9af8bde40f (patch)
treebf1cd49bb939c74d3225e1b21ec6db328e8aae49 /src/net/http/export_test.go
parent6c4e90a99edaf50a6825e04816756cd10808583c (diff)
downloadgo-bd68b8abc2e3ceaa3b9bde98568a4a9af8bde40f.tar.xz
net/http: TimeoutHandler should start timer when serving request
TimeoutHandler was starting the Timer when the handler was created, instead of when serving a request. It also was sharing it between multiple requests, which is incorrect, as the requests might start at different times. Store the timeout duration and create the Timer when ServeHTTP is called. Different requests will have different timers. The testing plumbing was simplified to store the channel used to control when timeout happens. It overrides the regular timer. Fixes #14568. Change-Id: I4bd51a83f412396f208682d3ae5e382db5f8dc81 Reviewed-on: https://go-review.googlesource.com/20046 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/net/http/export_test.go')
-rw-r--r--src/net/http/export_test.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/net/http/export_test.go b/src/net/http/export_test.go
index e14181a21b..94d55ab2f6 100644
--- a/src/net/http/export_test.go
+++ b/src/net/http/export_test.go
@@ -59,9 +59,9 @@ func SetTestHookServerServe(fn func(*Server, net.Listener)) { testHookServerServ
func NewTestTimeoutHandler(handler Handler, ch <-chan time.Time) Handler {
return &timeoutHandler{
- handler: handler,
- timeout: func() <-chan time.Time { return ch },
- // (no body and nil cancelTimer)
+ handler: handler,
+ testTimeout: ch,
+ // (no body)
}
}