Commit cf147af3 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

http2: fix build for Go 1.4 users

Request.Cancel was added in Go 1.5.

Change-Id: Iff28824315a58956fcfcb36d9bca6228cf6ea4f6
Reviewed-on: https://go-review.googlesource.com/17822Reviewed-by: 's avatarQi Zhao <zhaoq@google.com>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 08a7b454
......@@ -2,12 +2,10 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build !go1.6
// +build go1.5
package http2
import "net/http"
func configureTransport(t1 *http.Transport) error {
return errTransportVersion
}
func requestCancel(req *http.Request) <-chan struct{} { return req.Cancel }
// 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 }
// 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.6
package http2
import "net/http"
func configureTransport(t1 *http.Transport) error {
return errTransportVersion
}
......@@ -581,7 +581,7 @@ func (cc *ClientConn) RoundTrip(req *http.Request) (*http.Response, error) {
res.Request = req
res.TLS = cc.tlsState
return res, nil
case <-req.Cancel:
case <-requestCancel(req):
cs.abortRequestBodyWrite()
return nil, errRequestCanceled
case err := <-bodyCopyErrc:
......@@ -958,7 +958,7 @@ func (rl *clientConnReadLoop) processHeaderBlockFragment(frag []byte, streamID u
cs.bufPipe = pipe{b: buf}
cs.bytesRemain = res.ContentLength
res.Body = transportResponseBody{cs}
go cs.awaitRequestCancel(cs.req.Cancel)
go cs.awaitRequestCancel(requestCancel(cs.req))
if cs.requestedGzip && res.Header.Get("Content-Encoding") == "gzip" {
res.Header.Del("Content-Encoding")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment