author | Dave Day
<djd@golang.org> 2016-04-22 22:19:27 UTC |
committer | Dave Day
<djd@golang.org> 2016-04-22 23:03:51 UTC |
parent | 815d315ead425c4365077d904a2331ee9e179820 |
http2/go15.go | +0 | -11 |
http2/not_go15.go | +0 | -11 |
http2/transport.go | +2 | -3 |
diff --git a/http2/go15.go b/http2/go15.go deleted file mode 100644 index f0a5624..0000000 --- a/http2/go15.go +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build go1.5 - -package http2 - -import "net/http" - -func requestCancel(req *http.Request) <-chan struct{} { return req.Cancel } diff --git a/http2/not_go15.go b/http2/not_go15.go deleted file mode 100644 index d0fa5c8..0000000 --- a/http2/not_go15.go +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !go1.5 - -package http2 - -import "net/http" - -func requestCancel(req *http.Request) <-chan struct{} { return nil } diff --git a/http2/transport.go b/http2/transport.go index b5907da..3284faa 100644 --- a/http2/transport.go +++ b/http2/transport.go @@ -683,7 +683,6 @@ func (cc *ClientConn) RoundTrip(req *http.Request) (*http.Response, error) { } readLoopResCh := cs.resc - requestCanceledCh := requestCancel(req) bodyWritten := false for { @@ -717,7 +716,7 @@ func (cc *ClientConn) RoundTrip(req *http.Request) (*http.Response, error) { cs.abortRequestBodyWrite(errStopReqBodyWriteAndCancel) } return nil, errTimeout - case <-requestCanceledCh: + case <-req.Cancel: cc.forgetStreamID(cs.ID) if !hasBody || bodyWritten { cc.writeStreamReset(cs.ID, ErrCodeCancel, nil) @@ -1285,7 +1284,7 @@ func (rl *clientConnReadLoop) handleResponse(cs *clientStream, f *MetaHeadersFra cs.bufPipe = pipe{b: buf} cs.bytesRemain = res.ContentLength res.Body = transportResponseBody{cs} - go cs.awaitRequestCancel(requestCancel(cs.req)) + go cs.awaitRequestCancel(cs.req.Cancel) if cs.requestedGzip && res.Header.Get("Content-Encoding") == "gzip" { res.Header.Del("Content-Encoding")