diff options
| author | Brad Fitzpatrick <bradfitz@golang.org> | 2016-07-09 17:24:45 -0700 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2016-07-11 04:33:31 +0000 |
| commit | 54ffdf364f77c62ffeb205debe26347ca5961373 (patch) | |
| tree | bde248708757196c8bb6f81ee7f56bd28f22e4af /src | |
| parent | 54b499e3f1d3ef37765c209919d30f0abf55a2e1 (diff) | |
| download | go-54ffdf364f77c62ffeb205debe26347ca5961373.tar.xz | |
net/http: fix vet warning of leaked context in error paths
Updates #16230
Change-Id: Ie38f85419c41c00108f8843960280428a39789b5
Reviewed-on: https://go-review.googlesource.com/24850
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src')
| -rw-r--r-- | src/net/http/server.go | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/net/http/server.go b/src/net/http/server.go index 7c3237c4cd..9bf4d667e2 100644 --- a/src/net/http/server.go +++ b/src/net/http/server.go @@ -775,9 +775,6 @@ func (c *conn) readRequest(ctx context.Context) (w *response, err error) { return nil, badRequestError("unsupported protocol version") } - ctx, cancelCtx := context.WithCancel(ctx) - req.ctx = ctx - c.lastMethod = req.Method c.r.setInfiniteReadLimit() @@ -804,6 +801,8 @@ func (c *conn) readRequest(ctx context.Context) (w *response, err error) { } delete(req.Header, "Host") + ctx, cancelCtx := context.WithCancel(ctx) + req.ctx = ctx req.RemoteAddr = c.remoteAddr req.TLS = c.tlsState if body, ok := req.Body.(*body); ok { |
