diff options
| author | Brad Fitzpatrick <bradfitz@golang.org> | 2014-09-24 17:01:54 -0700 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2014-09-24 17:01:54 -0700 |
| commit | 446524269ee152b8053d44117887bc3cc8d5ef9d (patch) | |
| tree | 29c8f4f202edb95b43d248e46c3f148bc44c3e96 /src/net/http/server.go | |
| parent | e6f21be3f48802f18013a7e95bb3850882ab96e3 (diff) | |
| download | go-446524269ee152b8053d44117887bc3cc8d5ef9d.tar.xz | |
net/http: check for CloseWrite interface, not TCPConn implementation
Fixes #8724
LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/148040043
Diffstat (limited to 'src/net/http/server.go')
| -rw-r--r-- | src/net/http/server.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/net/http/server.go b/src/net/http/server.go index 8f2b777b29..7ad0bcbc20 100644 --- a/src/net/http/server.go +++ b/src/net/http/server.go @@ -1064,15 +1064,21 @@ func (c *conn) close() { // This timeout is somewhat arbitrary (~latency around the planet). const rstAvoidanceDelay = 500 * time.Millisecond +type closeWriter interface { + CloseWrite() error +} + +var _ closeWriter = (*net.TCPConn)(nil) + // closeWrite flushes any outstanding data and sends a FIN packet (if // client is connected via TCP), signalling that we're done. We then -// pause for a bit, hoping the client processes it before `any +// pause for a bit, hoping the client processes it before any // subsequent RST. // // See http://golang.org/issue/3595 func (c *conn) closeWriteAndWait() { c.finalFlush() - if tcp, ok := c.rwc.(*net.TCPConn); ok { + if tcp, ok := c.rwc.(closeWriter); ok { tcp.CloseWrite() } time.Sleep(rstAvoidanceDelay) |
