]> Cypherpunks repositories - gostls13.git/commit
net/http: fix race in TimeoutHandler
authorBrad Fitzpatrick <bradfitz@golang.org>
Mon, 14 Dec 2015 01:04:07 +0000 (01:04 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 14 Dec 2015 14:55:37 +0000 (14:55 +0000)
commit0478f7b9d6e9e0461e67716f003f4dbf26bf634d
tree5362a6590676b5bb262ab2180e4db384c7592f62
parent24a7955c74e5617492c256bfad03904d6f169b10
net/http: fix race in TimeoutHandler

New implementation of TimeoutHandler: buffer everything to memory.

All or nothing: either the handler finishes completely within the
timeout (in which case the wrapper writes it all), or it misses the
timeout and none of it gets written, in which case handler wrapper can
reliably print the error response without fear that some of the
wrapped Handler's code already wrote to the output.

Now the goroutine running the wrapped Handler has its own write buffer
and Header copy.

Document the limitations.

Fixes #9162

Change-Id: Ia058c1d62cefd11843e7a2fc1ae1609d75de2441
Reviewed-on: https://go-review.googlesource.com/17752
Reviewed-by: David Symonds <dsymonds@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
src/net/http/export_test.go
src/net/http/serve_test.go
src/net/http/server.go