]> Cypherpunks repositories - gostls13.git/commit
net/http: TimeoutHandler should start timer when serving request
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Mon, 29 Feb 2016 15:06:57 +0000 (12:06 -0300)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 7 Mar 2016 23:42:19 +0000 (23:42 +0000)
commitbd68b8abc2e3ceaa3b9bde98568a4a9af8bde40f
treebf1cd49bb939c74d3225e1b21ec6db328e8aae49
parent6c4e90a99edaf50a6825e04816756cd10808583c
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>
src/net/http/export_test.go
src/net/http/serve_test.go
src/net/http/server.go