From: Brad Fitzpatrick Date: Sun, 10 Jul 2016 00:24:45 +0000 (-0700) Subject: net/http: fix vet warning of leaked context in error paths X-Git-Tag: go1.7rc3~1^2~31 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=54ffdf364f77c62ffeb205debe26347ca5961373;p=gostls13.git 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 Reviewed-by: Josh Bleecher Snyder TryBot-Result: Gobot Gobot --- 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 {